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 |
|
---|
28 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
29 | [View("Feature Correlation View")]
|
---|
30 | [Content(typeof(DataAnalysisProblemData), false)]
|
---|
31 | public partial class FeatureCorrelationView : AbstractFeatureCorrelationView {
|
---|
32 |
|
---|
33 | private FeatureCorrelationCache correlationCache;
|
---|
34 |
|
---|
35 | public FeatureCorrelationView()
|
---|
36 | : base() {
|
---|
37 | InitializeComponent();
|
---|
38 | correlationCache = new FeatureCorrelationCache();
|
---|
39 | }
|
---|
40 |
|
---|
41 | protected override void OnContentChanged() {
|
---|
42 | correlationCache.Reset();
|
---|
43 | base.OnContentChanged();
|
---|
44 | }
|
---|
45 |
|
---|
46 | protected override void CalculateCorrelation() {
|
---|
47 | if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null) {
|
---|
48 | FeatureCorrelationEnums.CorrelationCalculators calc = (FeatureCorrelationEnums.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue;
|
---|
49 | FeatureCorrelationEnums.Partitions partition = (FeatureCorrelationEnums.Partitions)PartitionComboBox.SelectedValue;
|
---|
50 | DataGridView.Columns.Clear();
|
---|
51 | DataGridView.Enabled = false;
|
---|
52 | double[,] corr = correlationCache.GetCorrelation(calc, partition);
|
---|
53 | if (corr == null) {
|
---|
54 | fcc.CalculateElements(calc, partition);
|
---|
55 | } else {
|
---|
56 | SetNewCorrelation(corr, calc);
|
---|
57 | UpdateDataGrid();
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculators calc) {
|
---|
63 | DoubleRange range = FeatureCorrelationEnums.calculatorInterval[calc];
|
---|
64 | HeatMap hm = new HeatMap(elements, "", range.End, range.Start);
|
---|
65 | hm.RowNames = Content.Dataset.DoubleVariables;
|
---|
66 | hm.ColumnNames = Content.Dataset.DoubleVariables;
|
---|
67 | currentCorrelation = hm;
|
---|
68 | }
|
---|
69 |
|
---|
70 | protected override void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e) {
|
---|
71 | if (InvokeRequired) {
|
---|
72 | Invoke(new FeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(Content_CorrelationCalculationFinished), sender, e);
|
---|
73 | } else {
|
---|
74 | correlationCache.SetCorrelation(e.Calculcator, e.Partition, e.Correlation);
|
---|
75 | SetNewCorrelation(e.Correlation, e.Calculcator);
|
---|
76 | UpdateDataGrid();
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | protected override void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e) {
|
---|
81 | DataGridView.Columns[e.Index].Visible = e.NewValue == CheckState.Checked;
|
---|
82 | DataGridView.Rows[GetRowIndexOfVirtualindex(e.Index)].Visible = e.NewValue == CheckState.Checked;
|
---|
83 | }
|
---|
84 | }
|
---|
85 | } |
---|