Changeset 712 for trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ConfusionMatrixEvaluator.cs
- Timestamp:
- 11/05/08 21:34:12 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ConfusionMatrixEvaluator.cs
r702 r712 43 43 public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) { 44 44 IntMatrixData matrix = GetVariableValue<IntMatrixData>("ConfusionMatrix", scope, false, false); 45 if (matrix == null) {45 if (matrix == null) { 46 46 matrix = new IntMatrixData(new int[classes.Length, classes.Length]); 47 47 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("ConfusionMatrix"), matrix)); … … 49 49 50 50 int nSamples = end - start; 51 for (int sample = start; sample < end; sample++) {51 for (int sample = start; sample < end; sample++) { 52 52 double est = evaluator.Evaluate(sample); 53 double origClass = dataset.GetValue( targetVariable,sample);53 double origClass = dataset.GetValue(sample, targetVariable); 54 54 int estClassIndex = -1; 55 55 // if estimation is lower than the smallest threshold value -> estimated class is the lower class 56 if (est < thresholds[0]) estClassIndex = 0;56 if (est < thresholds[0]) estClassIndex = 0; 57 57 // if estimation is larger (or equal) than the largest threshold value -> estimated class is the upper class 58 else if (est >= thresholds[thresholds.Length - 1]) estClassIndex = classes.Length - 1;58 else if (est >= thresholds[thresholds.Length - 1]) estClassIndex = classes.Length - 1; 59 59 else { 60 60 // otherwise the estimated class is the class which upper threshold is larger than the estimated value 61 for (int k = 0; k < thresholds.Length; k++) {62 if (thresholds[k] > est) {61 for (int k = 0; k < thresholds.Length; k++) { 62 if (thresholds[k] > est) { 63 63 estClassIndex = k; 64 64 break; … … 68 68 69 69 // find the first threshold index that is larger to the original value 70 int origClassIndex = classes.Length -1;71 for (int i = 0; i < thresholds.Length; i++) {72 if (origClass < thresholds[i]) {70 int origClassIndex = classes.Length - 1; 71 for (int i = 0; i < thresholds.Length; i++) { 72 if (origClass < thresholds[i]) { 73 73 origClassIndex = i; 74 74 break;
Note: See TracChangeset
for help on using the changeset viewer.