Changeset 7022
- Timestamp:
- 11/21/11 15:38:39 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionEstimatedClassValuesView.cs
r6982 r7022 24 24 using System.Linq; 25 25 using System.Windows.Forms; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Data; 27 28 using HeuristicLab.MainForm; … … 96 97 97 98 int classValuesCount = Content.ProblemData.ClassValues.Count; 98 int modelCount = Content.Model.Models.Count();99 string[,] values = new string[indizes.Length, 5 + classValuesCount + modelCount];99 int solutionsCount = Content.ClassificationSolutions.Count(); 100 string[,] values = new string[indizes.Length, 5 + classValuesCount + solutionsCount]; 100 101 double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray(); 101 102 List<List<double?>> estimatedValuesVector = GetEstimatedValues(SamplesComboBox.SelectedItem.ToString(), indizes, … … 107 108 values[i, 1] = target[i].ToString(); 108 109 //display only indices and target values if no models are present 109 if (i >= estimatedClassValues.Length) continue; 110 111 values[i, 2] = estimatedClassValues[i].ToString(); 112 values[i, 3] = (target[i] == estimatedClassValues[i]).ToString(); 113 var groups = estimatedValuesVector[i].GroupBy(x => x).Select(g => new { Key = g.Key, Count = g.Count() }).ToList(); 114 var estimationCount = groups.Where(g => g.Key != null).Select(g => g.Count).Sum(); 115 values[i, 4] = (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString(); 116 for (int classIndex = 0; classIndex < Content.ProblemData.ClassValues.Count; classIndex++) { 117 var group = groups.Where(g => g.Key == Content.ProblemData.ClassValues[classIndex]).SingleOrDefault(); 118 if (group == null) values[i, 5 + classIndex] = 0.ToString(); 119 else values[i, 5 + classIndex] = group.Count.ToString(); 110 if (solutionsCount > 0) { 111 values[i, 2] = estimatedClassValues[i].ToString(); 112 values[i, 3] = (target[i].IsAlmost(estimatedClassValues[i])).ToString(); 113 var groups = 114 estimatedValuesVector[i].GroupBy(x => x).Select(g => new { Key = g.Key, Count = g.Count() }).ToList(); 115 var estimationCount = groups.Where(g => g.Key != null).Select(g => g.Count).Sum(); 116 values[i, 4] = 117 (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString(); 118 for (int classIndex = 0; classIndex < Content.ProblemData.ClassValues.Count; classIndex++) { 119 var group = groups.Where(g => g.Key == Content.ProblemData.ClassValues[classIndex]).SingleOrDefault(); 120 if (group == null) values[i, 5 + classIndex] = 0.ToString(); 121 else values[i, 5 + classIndex] = group.Count.ToString(); 122 } 123 for (int modelIndex = 0; modelIndex < estimatedValuesVector[i].Count; modelIndex++) { 124 values[i, 5 + classValuesCount + modelIndex] = estimatedValuesVector[i][modelIndex] == null 125 ? string.Empty 126 : estimatedValuesVector[i][modelIndex].ToString(); 127 } 120 128 } 121 for (int modelIndex = 0; modelIndex < estimatedValuesVector[i].Count; modelIndex++) {122 values[i, 5 + classValuesCount + modelIndex] = estimatedValuesVector[i][modelIndex] == null123 ? string.Empty124 : estimatedValuesVector[i][modelIndex].ToString();125 }126 127 129 } 128 130
Note: See TracChangeset
for help on using the changeset viewer.