Changeset 712 for trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/AccuracyEvaluator.cs
- Timestamp:
- 11/05/08 21:34:12 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/AccuracyEvaluator.cs
r702 r712 45 45 public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) { 46 46 DoubleData accuracy = GetVariableValue<DoubleData>("Accuracy", scope, false, false); 47 if (accuracy == null) {47 if (accuracy == null) { 48 48 accuracy = new DoubleData(); 49 49 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Accuracy"), accuracy)); … … 52 52 int nSamples = end - start; 53 53 int nCorrect = 0; 54 for (int sample = start; sample < end; sample++) {54 for (int sample = start; sample < end; sample++) { 55 55 double est = evaluator.Evaluate(sample); 56 double origClass = dataset.GetValue( targetVariable, sample);56 double origClass = dataset.GetValue(sample, targetVariable); 57 57 double estClass = double.NaN; 58 58 // if estimation is lower than the smallest threshold value -> estimated class is the lower class 59 if (est < thresholds[0]) estClass = classes[0];59 if (est < thresholds[0]) estClass = classes[0]; 60 60 // if estimation is larger (or equal) than the largest threshold value -> estimated class is the upper class 61 else if (est >= thresholds[thresholds.Length - 1]) estClass = classes[classes.Length - 1];61 else if (est >= thresholds[thresholds.Length - 1]) estClass = classes[classes.Length - 1]; 62 62 else { 63 63 // otherwise the estimated class is the class which upper threshold is larger than the estimated value 64 for (int k = 0; k < thresholds.Length; k++) {65 if (thresholds[k] > est) {64 for (int k = 0; k < thresholds.Length; k++) { 65 if (thresholds[k] > est) { 66 66 estClass = classes[k]; 67 67 break; … … 69 69 } 70 70 } 71 if (Math.Abs(estClass - origClass) < EPSILON) nCorrect++;71 if (Math.Abs(estClass - origClass) < EPSILON) nCorrect++; 72 72 } 73 73 accuracy.Data = nCorrect / (double)nSamples;
Note: See TracChangeset
for help on using the changeset viewer.