1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System.Windows.Forms;
|
---|
23 | using HeuristicLab.Analysis;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.MainForm;
|
---|
26 | using HeuristicLab.MainForm.WindowsForms;
|
---|
27 | using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
30 | [View("Feature Correlation View")]
|
---|
31 | [Content(typeof(DataAnalysisProblemData), false)]
|
---|
32 | public partial class FeatureCorrelationView : AbstractFeatureCorrelationView {
|
---|
33 |
|
---|
34 | private FeatureCorrelationCache correlationCache;
|
---|
35 |
|
---|
36 | public FeatureCorrelationView()
|
---|
37 | : base() {
|
---|
38 | InitializeComponent();
|
---|
39 | correlationCache = new FeatureCorrelationCache();
|
---|
40 | }
|
---|
41 |
|
---|
42 | protected override void OnContentChanged() {
|
---|
43 | correlationCache.Reset();
|
---|
44 | base.OnContentChanged();
|
---|
45 | }
|
---|
46 |
|
---|
47 | protected override void CalculateCorrelation() {
|
---|
48 | if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null) {
|
---|
49 | FCE.CorrelationCalculators calc = (FCE.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue;
|
---|
50 | FCE.Partitions partition = (FCE.Partitions)PartitionComboBox.SelectedValue;
|
---|
51 | DataGridView.Columns.Clear();
|
---|
52 | DataGridView.Enabled = false;
|
---|
53 | double[,] corr = correlationCache.GetCorrelation(calc, partition);
|
---|
54 | if (corr == null) {
|
---|
55 | fcc.CalculateElements(calc, partition);
|
---|
56 | } else {
|
---|
57 | SetNewCorrelation(corr, calc);
|
---|
58 | UpdateDataGrid();
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | private void SetNewCorrelation(double[,] elements, FCE.CorrelationCalculators calc) {
|
---|
64 | DoubleRange range = FCE.calculatorInterval[calc];
|
---|
65 | HeatMap hm = new HeatMap(elements, "", range.End, range.Start);
|
---|
66 | hm.RowNames = Content.Dataset.DoubleVariables;
|
---|
67 | hm.ColumnNames = Content.Dataset.DoubleVariables;
|
---|
68 | currentCorrelation = hm;
|
---|
69 | }
|
---|
70 |
|
---|
71 | protected override void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e) {
|
---|
72 | if (InvokeRequired) {
|
---|
73 | Invoke(new FeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(Content_CorrelationCalculationFinished), sender, e);
|
---|
74 | } else {
|
---|
75 | correlationCache.SetCorrelation(e.Calculcator, e.Partition, e.Correlation);
|
---|
76 | SetNewCorrelation(e.Correlation, e.Calculcator);
|
---|
77 | UpdateDataGrid();
|
---|
78 | }
|
---|
79 | }
|
---|
80 | }
|
---|
81 | } |
---|