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/VarianceAccountedForEvaluator.cs

    r400 r479  
    5353
    5454
    55     public override double Evaluate(IScope scope, IFunctionTree functionTree, int targetVariable, Dataset dataset) {
    56       int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
    57       int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
    58       double[] errors = new double[trainingEnd-trainingStart];
    59       double[] originalTargetVariableValues = new double[trainingEnd-trainingStart];
    60       double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    61       for(int sample = trainingStart; sample < trainingEnd; sample++) {
    62         double estimated = evaluator.Evaluate(sample);
    63         double original = dataset.GetValue(sample, targetVariable);
     55    public override double Evaluate(int start, int end) {
     56      int nSamples = end - start;
     57      double[] errors = new double[nSamples];
     58      double[] originalTargetVariableValues = new double[nSamples];
     59      for(int sample = start; sample < end; sample++) {
     60        double estimated = GetEstimatedValue(sample);
     61        double original = GetOriginalValue(sample);
    6462        if(!double.IsNaN(original) && !double.IsInfinity(original)) {
    65           if(double.IsNaN(estimated) || double.IsInfinity(estimated))
    66             estimated = targetMean + maximumPunishment;
    67           else if(estimated > (targetMean + maximumPunishment))
    68             estimated = targetMean + maximumPunishment;
    69           else if(estimated < (targetMean - maximumPunishment))
    70             estimated = targetMean - maximumPunishment;
     63          errors[sample - start] = original - estimated;
     64          originalTargetVariableValues[sample - start] = original;
    7165        }
    72 
    73         errors[sample-trainingStart] = original - estimated;
    74         originalTargetVariableValues[sample-trainingStart] = original;
    7566      }
    76       scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (trainingEnd-trainingStart);
    77 
    7867      double errorsVariance = Statistics.Variance(errors);
    7968      double originalsVariance = Statistics.Variance(originalTargetVariableValues);
Note: See TracChangeset for help on using the changeset viewer.