- Timestamp:
- 01/02/10 18:10:15 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ClassificationMeanSquaredErrorEvaluator.cs ¶
r2328 r2578 24 24 using HeuristicLab.Data; 25 25 using HeuristicLab.Common; 26 using HeuristicLab.GP.Interfaces; 27 using System.Linq; 28 using HeuristicLab.DataAnalysis; 26 29 27 30 namespace HeuristicLab.GP.StructureIdentification.Classification { … … 40 43 } 41 44 42 public override void Evaluate(IScope scope, I TreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {45 public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) { 43 46 double errorsSquaredSum = 0; 47 double[] estimatedValues = evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray(); 44 48 for (int sample = start; sample < end; sample++) { 45 double estimated = evaluator.Evaluate(sample);46 49 double original = dataset.GetValue(sample, targetVariable); 47 50 if (!double.IsNaN(original) && !double.IsInfinity(original)) { 48 double error = estimated - original;51 double error = estimatedValues[sample - start] - original; 49 52 // between classes use squared error 50 53 // on the lower end and upper end only add linear error if the absolute error is larger than 1 … … 57 60 } 58 61 } 62 59 63 } 60 64 -
TabularUnified trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/GPClassificationEvaluatorBase.cs ¶
r2577 r2578 24 24 using HeuristicLab.Data; 25 25 using HeuristicLab.DataAnalysis; 26 using HeuristicLab.GP.Interfaces; 26 27 27 28 namespace HeuristicLab.GP.StructureIdentification.Classification { … … 33 34 } 34 35 35 public override void Evaluate(IScope scope, I TreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {36 public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) { 36 37 37 38 ItemList<DoubleData> classes = GetVariableValue<ItemList<DoubleData>>("TargetClassValues", scope, true); 38 39 double[] classesArr = new double[classes.Count]; 39 for (int i = 0; i < classesArr.Length; i++) classesArr[i] = classes[i].Data;40 for (int i = 0; i < classesArr.Length; i++) classesArr[i] = classes[i].Data; 40 41 Array.Sort(classesArr); 41 42 double[] thresholds = new double[classes.Count - 1]; 42 for (int i = 0; i < classesArr.Length - 1; i++) {43 for (int i = 0; i < classesArr.Length - 1; i++) { 43 44 thresholds[i] = (classesArr[i] + classesArr[i + 1]) / 2.0; 44 45 } 45 46 46 Evaluate(scope, evaluator, dataset, targetVariable, classesArr, thresholds, start, end);47 Evaluate(scope, tree, evaluator, dataset, targetVariable, classesArr, thresholds, start, end); 47 48 } 48 49 49 public abstract void Evaluate(IScope scope, I TreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end);50 public abstract void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end); 50 51 } 51 52 }
Note: See TracChangeset
for help on using the changeset viewer.