Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/14/09 09:34:08 (16 years ago)
Author:
gkronber
Message:

Fixed incorrect evaluation in MSE evaluators when the original values contain NaNs. #615 (Evaluation of HL3 function trees should be equivalent to evaluation in HL2)

Location:
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators
Files:
2 edited

Legend:

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

    r712 r1794  
    5454      double errorsSquaredSum = 0;
    5555      int rows = end - start;
     56      int n = 0;
    5657      for (int sample = start; sample < end; sample++) {
    5758        double estimated = evaluator.Evaluate(sample);
     
    6364          double error = estimated - original;
    6465          errorsSquaredSum += error * error;
     66          n++;
    6567        }
    6668        // check the limit and stop as soon as we hit the limit
    6769        if (errorsSquaredSum / rows >= qualityLimit) {
    68           mse.Data = errorsSquaredSum / (sample - start + 1); // return estimated MSE (when the remaining errors are on average the same)
     70          mse.Data = errorsSquaredSum / (n + 1); // return estimated MSE (when the remaining errors are on average the same)
    6971          return;
    7072        }
    7173      }
    72       errorsSquaredSum /= rows;
     74      errorsSquaredSum /= n;
    7375      if (double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
    7476        errorsSquaredSum = double.MaxValue;
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/MeanSquaredErrorEvaluator.cs

    r712 r1794  
    4545    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {
    4646      double errorsSquaredSum = 0;
     47      int n = 0;
    4748      for (int sample = start; sample < end; sample++) {
    4849        double original = dataset.GetValue(sample, targetVariable);
     
    5455          double error = estimated - original;
    5556          errorsSquaredSum += error * error;
     57          n++;
    5658        }
    5759      }
    5860
    59       errorsSquaredSum /= (end - start);
     61      errorsSquaredSum /= n;
    6062      if (double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
    6163        errorsSquaredSum = double.MaxValue;
Note: See TracChangeset for help on using the changeset viewer.