Changeset 702 for trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs
- Timestamp:
- 10/29/08 11:21:04 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs
r656 r702 30 30 namespace HeuristicLab.GP.StructureIdentification { 31 31 public class EarlyStoppingMeanSquaredErrorEvaluator : MeanSquaredErrorEvaluator { 32 private double qualityLimit;33 32 public override string Description { 34 33 get { … … 44 43 } 45 44 46 public override IOperation Apply(IScope scope) { 47 qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, false).Data; 48 return base.Apply(scope); 49 } 45 // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE 46 public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 47 double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, false).Data; 48 DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false); 49 if(mse == null) { 50 mse = new DoubleData(); 51 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse)); 52 } 50 53 51 // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE52 public override void Evaluate(int start, int end) {53 54 double errorsSquaredSum = 0; 54 55 int rows = end - start; 55 56 for(int sample = start; sample < end; sample++) { 56 double estimated = GetEstimatedValue(sample); 57 double original = GetOriginalValue(sample); 58 SetOriginalValue(sample, estimated); 57 double estimated = evaluator.Evaluate(sample); 58 double original = dataset.GetValue(targetVariable, sample); 59 if(updateTargetValues) { 60 dataset.SetValue(targetVariable, sample, estimated); 61 } 59 62 if(!double.IsNaN(original) && !double.IsInfinity(original)) { 60 63 double error = estimated - original; … … 71 74 errorsSquaredSum = double.MaxValue; 72 75 } 76 73 77 mse.Data = errorsSquaredSum; 74 78 }
Note: See TracChangeset
for help on using the changeset viewer.