Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/14/09 13:46:57 (15 years ago)
Author:
gkronber
Message:

Refactored GP evaluation to make it possible to use different evaluators to interpret function trees. #615 (Evaluation of HL3 function trees should be equivalent to evaluation in HL2)

File:
1 edited

Legend:

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

    r712 r1796  
    4242    }
    4343
    44     public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {
     44    public override void Evaluate(IScope scope, ITreeEvaluator evaluator, IFunctionTree tree, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {
    4545      double errorsSquaredSum = 0.0;
    4646      double originalDeviationTotalSumOfSquares = 0.0;
    4747      double targetMean = dataset.GetMean(targetVariable, start, end);
     48
     49      double originalSum = 0.0;
     50      int n = 0;
    4851      for (int sample = start; sample < end; sample++) {
    49         double estimated = evaluator.Evaluate(sample);
     52        double estimated = evaluator.Evaluate(tree, sample);
    5053        double original = dataset.GetValue(sample, targetVariable);
    5154        if (updateTargetValues) {
     
    5659          errorsSquaredSum += error * error;
    5760
    58           double origDeviation = original - targetMean;
    59           originalDeviationTotalSumOfSquares += origDeviation * origDeviation;
     61          originalSum += original;
     62          n++;
     63        }
     64      }
     65
     66      double originalMean = originalSum / n;
     67      for(int sample = start; sample < end; sample++){
     68        double original = dataset.GetValue(sample, targetVariable);
     69        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
     70          original = original - originalMean;
     71          original = original * original;
     72          originalDeviationTotalSumOfSquares += original;
    6073        }
    6174      }
Note: See TracChangeset for help on using the changeset viewer.