- Timestamp:
- 08/24/11 13:12:16 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionEstimatedClassValuesView.cs
r6672 r6680 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Drawing; 23 24 using System.Linq; 24 25 using System.Windows.Forms; … … 33 34 ClassificationSolutionEstimatedClassValuesView { 34 35 private const string RowColumnName = "Row"; 35 private const string TargetClassValuesColumnName = "TargetVariable"; 36 private const string EstimatedClassValuesColumnName = "EstimatedClassValues"; 36 private const string TargetClassValuesColumnName = "Target Variable"; 37 private const string EstimatedClassValuesColumnName = "Estimated Class Values"; 38 private const string CorrectClassificationColumnName = "Correct Classification"; 37 39 private const string ConfidenceColumnName = "Confidence"; 38 40 … … 51 53 SamplesComboBox.Items.AddRange(new string[] { SamplesComboBoxAllSamples, SamplesComboBoxTrainingSamples, SamplesComboBoxTestSamples }); 52 54 SamplesComboBox.SelectedIndex = 0; 55 matrixView.DataGridView.RowPrePaint += new DataGridViewRowPrePaintEventHandler(DataGridView_RowPrePaint); 53 56 } 57 58 54 59 55 60 private void SamplesComboBox_SelectedIndexChanged(object sender, EventArgs e) { … … 92 97 int classValuesCount = Content.ProblemData.ClassValues.Count; 93 98 int modelCount = Content.Model.Models.Count(); 94 string[,] values = new string[indizes.Length, 4+ classValuesCount + modelCount];99 string[,] values = new string[indizes.Length, 5 + classValuesCount + modelCount]; 95 100 double[] target = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable); 96 101 List<List<double?>> estimatedValuesVector = GetEstimatedValues(SamplesComboBox.SelectedItem.ToString(), indizes, … … 102 107 values[i, 1] = target[i].ToString(); 103 108 values[i, 2] = estimatedClassValues[i].ToString(); 109 values[i, 3] = (target[i] == estimatedClassValues[i]).ToString(); 104 110 var groups = estimatedValuesVector[i].GroupBy(x => x).Select(g => new { Key = g.Key, Count = g.Count() }).ToList(); 105 111 var estimationCount = groups.Where(g => g.Key != null).Select(g => g.Count).Sum(); 106 values[i, 3] = (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString();112 values[i, 4] = (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString(); 107 113 for (int classIndex = 0; classIndex < Content.ProblemData.ClassValues.Count; classIndex++) { 108 114 var group = groups.Where(g => g.Key == Content.ProblemData.ClassValues[classIndex]).SingleOrDefault(); 109 if (group == null) values[i, 4+ classIndex] = 0.ToString();110 else values[i, 4+ classIndex] = group.Count.ToString();115 if (group == null) values[i, 5 + classIndex] = 0.ToString(); 116 else values[i, 5 + classIndex] = group.Count.ToString(); 111 117 } 112 118 for (int modelIndex = 0; modelIndex < estimatedValuesVector[i].Count; modelIndex++) { 113 values[i, 4+ classValuesCount + modelIndex] = estimatedValuesVector[i][modelIndex] == null119 values[i, 5 + classValuesCount + modelIndex] = estimatedValuesVector[i][modelIndex] == null 114 120 ? string.Empty 115 121 : estimatedValuesVector[i][modelIndex].ToString(); … … 119 125 120 126 StringMatrix matrix = new StringMatrix(values); 121 List<string> columnNames = new List<string>() { "Id", TargetClassValuesColumnName, EstimatedClassValuesColumnName, Co nfidenceColumnName };127 List<string> columnNames = new List<string>() { "Id", TargetClassValuesColumnName, EstimatedClassValuesColumnName, CorrectClassificationColumnName, ConfidenceColumnName }; 122 128 columnNames.AddRange(Content.ProblemData.ClassNames); 123 129 columnNames.AddRange(Content.Model.Models.Select(m => m.Name)); … … 125 131 matrix.SortableView = true; 126 132 matrixView.Content = matrix; 133 UpdateColoringOfRows(); 127 134 } 128 135 … … 150 157 } 151 158 159 private void DataGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { 160 if (InvokeRequired) { 161 Invoke(new EventHandler<DataGridViewRowPrePaintEventArgs>(DataGridView_RowPrePaint), sender, e); 162 return; 163 } 164 bool correctClassified = bool.Parse(matrixView.DataGridView[3, e.RowIndex].Value.ToString()); 165 matrixView.DataGridView.Rows[e.RowIndex].DefaultCellStyle.ForeColor = correctClassified ? Color.MediumSeaGreen : Color.Red; 166 } 152 167 153 168 private void UpdateColoringOfRows() { 169 if (InvokeRequired) { 170 Invoke((Action)UpdateColoringOfRows); 171 return; 172 } 173 //matrixView.DataGridView.SuspendRepaint(); 174 //for (int i = 0; i < matrixView.DataGridView.Rows.Count; i++) { 175 // bool correctClassified = bool.Parse(matrixView.Content.GetValue(i, 3)); 176 // matrixView.DataGridView.Rows[i].DefaultCellStyle.ForeColor = correctClassified ? Color.MediumSeaGreen : Color.Red; 177 //} 178 //matrixView.DataGridView.ResumeRepaint(true); 179 } 154 180 } 155 181 }
Note: See TracChangeset
for help on using the changeset viewer.