Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/08 11:21:04 (16 years ago)
Author:
gkronber
Message:

fixed #328 by restructuring evaluation operators to remove state in evaluation operators.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/MeanSquaredErrorEvaluator.cs

    r656 r702  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Operators;
     29using HeuristicLab.DataAnalysis;
    2930
    3031namespace HeuristicLab.GP.StructureIdentification {
    3132  public class MeanSquaredErrorEvaluator : GPEvaluatorBase {
    32     protected DoubleData mse;
    3333    public override string Description {
    3434      get {
     
    4343    }
    4444
    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) {
    5646      double errorsSquaredSum = 0;
    5747      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        }
    6153        if(!double.IsNaN(original) && !double.IsInfinity(original)) {
    6254          double error = estimated - original;
     
    6961        errorsSquaredSum = double.MaxValue;
    7062      }
     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
    7170      mse.Data = errorsSquaredSum;
    7271    }
Note: See TracChangeset for help on using the changeset viewer.