Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/10/08 11:08:07 (16 years ago)
Author:
gkronber
Message:

implemented #242 (All GP evaluators should support the 'UseEstimatedTargetValues' switch for autoregressive modelling).
Also used the chance to remove a lot of the code duplication and thus improve the readability of all GP evaluators.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/CoefficientOfDeterminationEvaluator.cs

    r400 r479  
    4343    }
    4444
    45     public override double Evaluate(IScope scope, IFunctionTree functionTree, int targetVariable, Dataset dataset) {
    46       int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
    47       int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
     45    public override double Evaluate(int start, int end) {
    4846      double errorsSquaredSum = 0.0;
    4947      double originalDeviationTotalSumOfSquares = 0.0;
    50       double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    51       for(int sample = trainingStart; sample < trainingEnd; sample++) {
    52         double estimated = evaluator.Evaluate(sample);
    53         double original = dataset.GetValue(sample, targetVariable);
     48      for(int sample = start; sample < end; sample++) {
     49        double estimated = GetEstimatedValue(sample);
     50        double original = GetOriginalValue(sample);
    5451        if(!double.IsNaN(original) && !double.IsInfinity(original)) {
    55           if(double.IsNaN(estimated) || double.IsInfinity(estimated))
    56             estimated = targetMean + maximumPunishment;
    57           else if(estimated > (targetMean + maximumPunishment))
    58             estimated = targetMean + maximumPunishment;
    59           else if(estimated < (targetMean - maximumPunishment))
    60             estimated = targetMean - maximumPunishment;
    61 
    6252          double error = estimated - original;
    6353          errorsSquaredSum += error * error;
    6454
    65           double origDeviation = original - targetMean;
     55          double origDeviation = original - TargetMean;
    6656          originalDeviationTotalSumOfSquares += origDeviation * origDeviation;
    6757        }
    6858      }
    69 
    70       scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (trainingEnd - trainingStart);
    7159
    7260      double quality = 1 - errorsSquaredSum / originalDeviationTotalSumOfSquares;
Note: See TracChangeset for help on using the changeset viewer.