Changeset 8862
- Timestamp:
- 10/30/12 14:22:20 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionAccuracyToCoveredSamples.cs
r8814 r8862 82 82 var solutions = Content.ClassificationSolutions; 83 83 double[] estimatedClassValues = null; 84 double[] classValues;84 double[] target; 85 85 OnlineAccuracyCalculator accuracyCalc = new OnlineAccuracyCalculator(); 86 86 87 int rows = 0; 88 double[] confidences = null; 89 90 classValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray(); 91 92 if (SamplesComboBox.SelectedItem.ToString().Equals(SamplesComboBoxAllSamples)) { 93 rows = Content.ProblemData.Dataset.Rows; 94 estimatedClassValues = Content.EstimatedClassValues.ToArray(); 95 confidences = weightCalc.GetConfidence(solutions, 96 Enumerable.Range(0, Content.ProblemData.Dataset.Rows), 97 estimatedClassValues, 98 weightCalc.GetAllClassDelegate()).ToArray(); 99 } else if (SamplesComboBox.SelectedItem.ToString().Equals(SamplesComboBoxTrainingSamples)) { 100 rows = Content.ProblemData.TrainingIndices.Count(); 101 estimatedClassValues = Content.EstimatedTrainingClassValues.ToArray(); 102 confidences = weightCalc.GetConfidence(solutions, 103 Content.ProblemData.TrainingIndices, 104 estimatedClassValues, 105 weightCalc.GetTrainingClassDelegate()).ToArray(); 106 } else if (SamplesComboBox.SelectedItem.ToString().Equals(SamplesComboBoxTestSamples)) { 107 rows = Content.ProblemData.TestIndices.Count(); 108 estimatedClassValues = Content.EstimatedTestClassValues.ToArray(); 109 confidences = weightCalc.GetConfidence(solutions, 110 Content.ProblemData.TestIndices, 111 estimatedClassValues, 112 weightCalc.GetTestClassDelegate()).ToArray(); 87 int[] indizes; 88 double[] confidences; 89 90 target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray(); 91 switch (SamplesComboBox.SelectedItem.ToString()) { 92 case SamplesComboBoxAllSamples: 93 indizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray(); 94 estimatedClassValues = Content.EstimatedClassValues.ToArray(); 95 confidences = weightCalc.GetConfidence(solutions, 96 Enumerable.Range(0, Content.ProblemData.Dataset.Rows), 97 estimatedClassValues, 98 weightCalc.GetAllClassDelegate()).ToArray(); 99 break; 100 case SamplesComboBoxTrainingSamples: 101 indizes = Content.ProblemData.TrainingIndices.ToArray(); 102 estimatedClassValues = Content.EstimatedTrainingClassValues.ToArray(); 103 confidences = weightCalc.GetConfidence(solutions, 104 Content.ProblemData.TrainingIndices, 105 estimatedClassValues, 106 weightCalc.GetTrainingClassDelegate()).ToArray(); 107 break; 108 case SamplesComboBoxTestSamples: 109 indizes = Content.ProblemData.TestIndices.ToArray(); 110 estimatedClassValues = Content.EstimatedTestClassValues.ToArray(); 111 confidences = weightCalc.GetConfidence(solutions, 112 Content.ProblemData.TestIndices, 113 estimatedClassValues, 114 weightCalc.GetTestClassDelegate()).ToArray(); 115 break; 116 default: 117 throw new ArgumentException(); 113 118 } 114 119 120 int row; 115 121 for (int i = 0; i < maxPoints; i++) { 116 122 double confidenceValue = (1.0 / (maxPoints - 1)) * i; 117 123 int notCovered = 0; 118 124 119 for (int j = 0; j < rows; j++) { 125 for (int j = 0; j < indizes.Length; j++) { 126 row = indizes[j]; 120 127 if (confidences[j] >= confidenceValue) { 121 accuracyCalc.Add( classValues[j], estimatedClassValues[j]);128 accuracyCalc.Add(target[row], estimatedClassValues[j]); 122 129 } else { 123 130 notCovered++; … … 126 133 127 134 accuracy[i + 1] = accuracyCalc.Accuracy; 128 if ( rows> 0) {129 covered[i] = 1.0 - (double)notCovered / (double) rows;135 if (indizes.Length > 0) { 136 covered[i] = 1.0 - (double)notCovered / (double)indizes.Length; 130 137 } 131 138 accuracyCalc.Reset();
Note: See TracChangeset
for help on using the changeset viewer.