- Timestamp:
- 09/24/12 18:48:16 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 10 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.Designer.cs
r8578 r8689 46 46 /// </summary> 47 47 private void InitializeComponent() { 48 this.components = new System.ComponentModel.Container(); 48 49 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AbstractFeatureCorrelationView)); 49 50 this.DataGridView = new System.Windows.Forms.DataGridView(); … … 59 60 this.CalculatingPanel = new System.Windows.Forms.Panel(); 60 61 this.CalculatingLabel = new System.Windows.Forms.Label(); 62 this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 63 this.ShowHideColumns = new System.Windows.Forms.ToolStripMenuItem(); 61 64 ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit(); 62 65 ((System.ComponentModel.ISupportInitialize)(this.PictureBox)).BeginInit(); … … 66 69 this.SplitContainer.SuspendLayout(); 67 70 this.CalculatingPanel.SuspendLayout(); 71 this.contextMenu.SuspendLayout(); 68 72 this.SuspendLayout(); 69 73 // … … 84 88 this.DataGridView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.DataGridView_ColumnHeaderMouseClick); 85 89 this.DataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DataGridView_KeyDown); 90 this.DataGridView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.DataGridView_MouseClick); 86 91 // 87 92 // HeatMapProgressBar … … 211 216 this.CalculatingLabel.TabIndex = 10; 212 217 this.CalculatingLabel.Text = "Calculating correlation..."; 218 // 219 // contextMenu 220 // 221 this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 222 this.ShowHideColumns}); 223 this.contextMenu.Name = "contextMenu"; 224 this.contextMenu.Size = new System.Drawing.Size(191, 26); 225 // 226 // ShowHideColumns 227 // 228 this.ShowHideColumns.Name = "ShowHideColumns"; 229 this.ShowHideColumns.Size = new System.Drawing.Size(190, 22); 230 this.ShowHideColumns.Text = "Show / Hide Columns"; 231 this.ShowHideColumns.Click += new System.EventHandler(this.ShowHideColumns_Click); 213 232 // 214 233 // AbstractFeatureCorrelationView … … 231 250 this.CalculatingPanel.ResumeLayout(false); 232 251 this.CalculatingPanel.PerformLayout(); 252 this.contextMenu.ResumeLayout(false); 233 253 this.ResumeLayout(false); 234 254 … … 249 269 protected System.Windows.Forms.Panel CalculatingPanel; 250 270 protected System.Windows.Forms.Label CalculatingLabel; 271 protected System.Windows.Forms.ContextMenuStrip contextMenu; 272 protected System.Windows.Forms.ToolStripMenuItem ShowHideColumns; 251 273 252 274 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.cs
r8578 r8689 30 30 using HeuristicLab.Common; 31 31 using HeuristicLab.Data.Views; 32 using HeuristicLab.DataAnalysis.Views; 32 33 using HeuristicLab.MainForm; 33 34 using HeuristicLab.MainForm.WindowsForms; … … 40 41 41 42 private int[] virtualRowIndices; 43 private VariableVisibilityDialog variableVisibility; 42 44 private List<KeyValuePair<int, SortOrder>> sortedColumnIndices; 43 45 private StringConvertibleMatrixView.RowComparer rowComparer; … … 82 84 if (Content != null) { 83 85 fcc.ProblemData = Content; 86 bool[] initialVisibility = SetInitialVisibilityOfColumns(); 87 88 variableVisibility = new VariableVisibilityDialog(Content.Dataset.DoubleVariables, initialVisibility); 89 variableVisibility.VariableVisibilityChanged += new ItemCheckEventHandler(variableVisibility_VariableVisibilityChanged); 84 90 CalculateCorrelation(); 85 91 } else { … … 88 94 } 89 95 } 96 97 protected virtual bool[] SetInitialVisibilityOfColumns() { 98 bool[] initialVisibility = new bool[Content.Dataset.DoubleVariables.Count()]; 99 int i = 0; 100 foreach (var variable in Content.Dataset.DoubleVariables) { 101 initialVisibility[i] = Content.AllowedInputVariables.Contains(variable); 102 i++; 103 } 104 return initialVisibility; 105 } 106 107 protected abstract void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e); 90 108 91 109 protected void CorrelationMeasureComboBox_SelectedChangeCommitted(object sender, System.EventArgs e) { … … 127 145 for (int i = 0; i < DataGridView.ColumnCount; i++) { 128 146 DataGridView.Columns[i].HeaderText = currentCorrelation.ColumnNames.ElementAt(i); 147 DataGridView.Columns[i].Visible = variableVisibility.Visibility[i]; 129 148 } 130 149 } … … 132 151 for (int i = 0; i < DataGridView.RowCount; i++) { 133 152 DataGridView.Rows[i].HeaderCell.Value = currentCorrelation.RowNames.ElementAt(virtualRowIndices[i]); 153 DataGridView.Rows[i].Visible = variableVisibility.Visibility[virtualRowIndices[i]]; 134 154 } 135 155 } … … 169 189 170 190 protected virtual Color GetDataPointColor(double value, double min, double max) { 191 if (double.IsNaN(value)) { 192 return Color.DarkGray; 193 } 171 194 IList<Color> colors = ColorGradient.Colors; 172 195 int index = (int)((colors.Count - 1) * (value - min) / (max - min)); … … 301 324 } 302 325 #endregion 326 327 protected void ShowHideColumns_Click(object sender, EventArgs e) { 328 variableVisibility.ShowDialog(); 329 } 330 331 protected void DataGridView_MouseClick(object sender, MouseEventArgs e) { 332 if (Content == null) return; 333 if (e.Button == MouseButtons.Right && DataGridView.Columns.Count != 0) 334 contextMenu.Show(MousePosition); 335 } 336 337 protected int GetRowIndexOfVirtualindex(int virtualIndex) { 338 if (virtualIndex < 0 || virtualIndex >= virtualRowIndices.Length) { 339 throw new ArgumentException("Virtual index is out of bounds"); 340 } 341 342 for (int i = 0; i < virtualRowIndices.Length; i++) { 343 if (virtualRowIndices[i] == virtualIndex) { 344 return i; 345 } 346 } 347 throw new ArgumentException("Virtual index was not found!"); 348 } 303 349 } 304 350 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.resx
r8578 r8689 1020 1020 </value> 1021 1021 </data> 1022 <metadata name="contextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 1023 <value>17, 17</value> 1024 </metadata> 1022 1025 </root> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationView.cs
r8578 r8689 78 78 } 79 79 } 80 81 protected override void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e) { 82 DataGridView.Columns[e.Index].Visible = e.NewValue == CheckState.Checked; 83 DataGridView.Rows[GetRowIndexOfVirtualindex(e.Index)].Visible = e.NewValue == CheckState.Checked; 84 } 80 85 } 81 86 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs
r8578 r8689 107 107 } 108 108 } 109 110 protected override void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e) { 111 DataGridView.Rows[GetRowIndexOfVirtualindex(e.Index)].Visible = e.NewValue == CheckState.Checked; 112 } 109 113 } 110 114 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r8679 r8689 126 126 <DependentUpon>ClassificationEnsembleSolutionModelView.cs</DependentUpon> 127 127 </Compile> 128 <Compile Include="Classification\ClassificationFeatureCorrelationView.cs"> 129 <SubType>UserControl</SubType> 130 </Compile> 131 <Compile Include="Classification\ClassificationFeatureCorrelationView.Designer.cs"> 132 <DependentUpon>ClassificationFeatureCorrelationView.cs</DependentUpon> 133 </Compile> 134 <Compile Include="Classification\ClassificationTimeframeFeatureCorrelationView.cs"> 135 <SubType>UserControl</SubType> 136 </Compile> 137 <Compile Include="Classification\ClassificationTimeframeFeatureCorrelationView.Designer.cs"> 138 <DependentUpon>ClassificationTimeframeFeatureCorrelationView.cs</DependentUpon> 139 </Compile> 128 140 <Compile Include="Classification\DiscriminantFunctionClassificationModelView.cs"> 129 141 <SubType>UserControl</SubType> … … 149 161 <Compile Include="DataAnalysisSolutionEvaluationView.Designer.cs"> 150 162 <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon> 163 </Compile> 164 <Compile Include="FeatureCorrelation\VariableVisibilityDialog.cs"> 165 <SubType>Form</SubType> 166 </Compile> 167 <Compile Include="FeatureCorrelation\VariableVisibilityDialog.Designer.cs"> 168 <DependentUpon>VariableVisibilityDialog.cs</DependentUpon> 151 169 </Compile> 152 170 <Compile Include="FeatureCorrelation\FeatureCorrelationView.cs"> … … 164 182 <Compile Include="ProblemDataView.Designer.cs"> 165 183 <DependentUpon>ProblemDataView.cs</DependentUpon> 184 </Compile> 185 <Compile Include="Regression\RegressionFeatureCorrelationView.cs"> 186 <SubType>UserControl</SubType> 187 </Compile> 188 <Compile Include="Regression\RegressionFeatureCorrelationView.Designer.cs"> 189 <DependentUpon>RegressionFeatureCorrelationView.cs</DependentUpon> 190 </Compile> 191 <Compile Include="Regression\RegressionTimeframeFeatureCorrelationView.cs"> 192 <SubType>UserControl</SubType> 193 </Compile> 194 <Compile Include="Regression\RegressionTimeframeFeatureCorrelationView.Designer.cs"> 195 <DependentUpon>RegressionTimeframeFeatureCorrelationView.cs</DependentUpon> 166 196 </Compile> 167 197 <Compile Include="Regression\RegressionEnsembleSolutionModelView.cs"> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataView.cs
r8593 r8689 45 45 46 46 protected void FeatureCorrelationButton_Click(object sender, System.EventArgs e) { 47 ViewHost viewHost = new ViewHost(); 48 viewHost.Content = (DataAnalysisProblemData)this.Content.Clone(); 49 viewHost.ViewType = typeof(FeatureCorrelationView); 50 viewHost.Show(); 47 Type viewType = MainFormManager.GetViewTypes(this.Content.GetType(), true).FirstOrDefault(t => typeof(AbstractFeatureCorrelationView).IsAssignableFrom(t)); 48 MainFormManager.MainForm.ShowContent(Content, viewType); 51 49 } 52 50 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/FeatureCorrelation/FeatureCorrelationCalculator.cs
r8578 r8689 111 111 112 112 IList<string> doubleVariableNames = dataset.DoubleVariables.ToList(); 113 OnlineCalculatorError error ;113 OnlineCalculatorError error = OnlineCalculatorError.None; 114 114 int length = doubleVariableNames.Count; 115 115 double[,] elements = new double[length, length]; … … 124 124 return; 125 125 } 126 127 126 IEnumerable<double> var1 = GetRelevantValues(problemData, partition, doubleVariableNames[i]); 128 127 IEnumerable<double> var2 = GetRelevantValues(problemData, partition, doubleVariableNames[j]); … … 130 129 elements[i, j] = CalculateElementWithCalculator(calc, var1, var2, out error); 131 130 131 if (!error.Equals(OnlineCalculatorError.None)) { 132 elements[i, j] = double.NaN; 133 } 132 134 elements[j, i] = elements[i, j]; 133 if (!error.Equals(OnlineCalculatorError.None)) {134 worker.ReportProgress(100);135 throw new ArgumentException("Calculator returned " + error + Environment.NewLine + "Maybe try another calculator.");136 }137 135 worker.ReportProgress((int)Math.Round((((Math.Pow(i, 2) + i) / 2 + j + 1.0) / calculations) * 100)); 138 136 } … … 153 151 154 152 IList<string> doubleVariableNames = dataset.DoubleVariables.ToList(); 155 OnlineCalculatorError error ;153 OnlineCalculatorError error = OnlineCalculatorError.None; 156 154 int length = doubleVariableNames.Count; 157 155 double[,] elements = new double[length, frames + 1]; … … 186 184 187 185 if (!error.Equals(OnlineCalculatorError.None)) { 188 worker.ReportProgress(100); 189 throw new ArgumentException("Calculator returned " + error + Environment.NewLine + "Maybe try another calculator."); 186 elements[i, j] = double.NaN; 190 187 } 191 188 worker.ReportProgress((int)((100.0 / calculations) * (i * (frames + 1) + j + 1))); -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/SpearmansRankCorrelationCoefficientCalculator.cs
r8542 r8689 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 27 28 28 29 public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) { 29 double rs = alglib.basestat.spearmancorr2(originalValues.ToArray(), estimatedValues.ToArray(), originalValues.Count()); 30 errorState = OnlineCalculatorError.None; 30 double rs = double.NaN; 31 try { 32 rs = alglib.basestat.spearmancorr2(originalValues.ToArray(), estimatedValues.ToArray(), originalValues.Count()); 33 errorState = OnlineCalculatorError.None; 34 } 35 catch (Exception ex) { 36 errorState = OnlineCalculatorError.InvalidValueAdded; 37 } 38 31 39 return rs; 32 40 }
Note: See TracChangeset
for help on using the changeset viewer.