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/MeanAbsolutePercentageErrorEvaluator.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 errorsSum = 0.0;
    49       for(int sample = trainingStart; sample < trainingEnd; sample++) {
    50         double estimated = evaluator.Evaluate(sample);
    51         double original = dataset.GetValue(sample, targetVariable);
     47      for(int sample = start; sample < end; sample++) {
     48        double estimated = GetEstimatedValue(sample);
     49        double original = GetOriginalValue(sample);
    5250        if(!double.IsNaN(original) && !double.IsInfinity(original)) {
    53           if(double.IsNaN(estimated) || double.IsInfinity(estimated))
    54             estimated = maximumPunishment;
    55           else if(estimated > maximumPunishment)
    56             estimated = maximumPunishment;
    57           else if(estimated < -maximumPunishment)
    58             estimated = -maximumPunishment;
    59 
    6051          double percent_error = Math.Abs((estimated - original) / original);
    6152          errorsSum += percent_error;
    6253        }
    6354      }
    64       int nSamples = trainingEnd - trainingStart;
    65       scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * nSamples;
    66       double quality = errorsSum / nSamples;
     55      double quality = errorsSum / (end - start);
    6756      if(double.IsNaN(quality) || double.IsInfinity(quality))
    6857        quality = double.MaxValue;
Note: See TracChangeset for help on using the changeset viewer.