Changeset 702 for trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/MeanSquaredErrorEvaluator.cs
- Timestamp:
- 10/29/08 11:21:04 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/MeanSquaredErrorEvaluator.cs
r656 r702 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Operators; 29 using HeuristicLab.DataAnalysis; 29 30 30 31 namespace HeuristicLab.GP.StructureIdentification { 31 32 public class MeanSquaredErrorEvaluator : GPEvaluatorBase { 32 protected DoubleData mse;33 33 public override string Description { 34 34 get { … … 43 43 } 44 44 45 public override IOperation Apply(IScope scope) { 46 mse = GetVariableValue<DoubleData>("MSE", scope, false, false); 47 if(mse == null) { 48 mse = new DoubleData(); 49 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse)); 50 } 51 52 return base.Apply(scope); 53 } 54 55 public override void Evaluate(int start, int end) { 45 public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 56 46 double errorsSquaredSum = 0; 57 47 for(int sample = start; sample < end; sample++) { 58 double original = GetOriginalValue(sample); 59 double estimated = GetEstimatedValue(sample); 60 SetOriginalValue(sample, estimated); 48 double original = dataset.GetValue(targetVariable, sample); 49 double estimated = evaluator.Evaluate(sample); 50 if(updateTargetValues) { 51 dataset.SetValue(targetVariable, sample, estimated); 52 } 61 53 if(!double.IsNaN(original) && !double.IsInfinity(original)) { 62 54 double error = estimated - original; … … 69 61 errorsSquaredSum = double.MaxValue; 70 62 } 63 64 DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false); 65 if(mse == null) { 66 mse = new DoubleData(); 67 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse)); 68 } 69 71 70 mse.Data = errorsSquaredSum; 72 71 }
Note: See TracChangeset
for help on using the changeset viewer.