Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2578


Ignore:
Timestamp:
01/02/10 18:10:15 (15 years ago)
Author:
gkronber
Message:

Implemented #824 (Refactor: ITreeEvaluator interface to provide a method that evaluates a tree on a range of samples.)

Location:
trunk/sources
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ClassificationMeanSquaredErrorEvaluator.cs

    r2328 r2578  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Common;
     26using HeuristicLab.GP.Interfaces;
     27using System.Linq;
     28using HeuristicLab.DataAnalysis;
    2629
    2730namespace HeuristicLab.GP.StructureIdentification.Classification {
     
    4043    }
    4144
    42     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {
     45    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {
    4346      double errorsSquaredSum = 0;
     47      double[] estimatedValues = evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray();
    4448      for (int sample = start; sample < end; sample++) {
    45         double estimated = evaluator.Evaluate(sample);
    4649        double original = dataset.GetValue(sample, targetVariable);
    4750        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
    48           double error = estimated - original;
     51          double error = estimatedValues[sample - start] - original;
    4952          // between classes use squared error
    5053          // on the lower end and upper end only add linear error if the absolute error is larger than 1
     
    5760          }
    5861        }
     62
    5963      }
    6064
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/GPClassificationEvaluatorBase.cs

    r2577 r2578  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.DataAnalysis;
     26using HeuristicLab.GP.Interfaces;
    2627
    2728namespace HeuristicLab.GP.StructureIdentification.Classification {
     
    3334    }
    3435
    35     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
     36    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
    3637
    3738      ItemList<DoubleData> classes = GetVariableValue<ItemList<DoubleData>>("TargetClassValues", scope, true);
    3839      double[] classesArr = new double[classes.Count];
    39       for(int i = 0; i < classesArr.Length; i++) classesArr[i] = classes[i].Data;
     40      for (int i = 0; i < classesArr.Length; i++) classesArr[i] = classes[i].Data;
    4041      Array.Sort(classesArr);
    4142      double[] thresholds = new double[classes.Count - 1];
    42       for(int i = 0; i < classesArr.Length - 1; i++) {
     43      for (int i = 0; i < classesArr.Length - 1; i++) {
    4344        thresholds[i] = (classesArr[i] + classesArr[i + 1]) / 2.0;
    4445      }
    4546
    46       Evaluate(scope, evaluator, dataset, targetVariable, classesArr, thresholds, start, end);
     47      Evaluate(scope, tree, evaluator, dataset, targetVariable, classesArr, thresholds, start, end);
    4748    }
    4849
    49     public abstract void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end);
     50    public abstract void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end);
    5051  }
    5152}
  • trunk/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/ConditionalEvaluatorBase.cs

    r2577 r2578  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.DataAnalysis;
     29using HeuristicLab.GP.Interfaces;
     30using HeuristicLab.Modeling;
    2931
    3032namespace HeuristicLab.GP.StructureIdentification.ConditionalEvaluation {
     
    4042    }
    4143
    42     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
     44    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
    4345      int maxTimeOffset = GetVariableValue<IntData>("MaxTimeOffset", scope, true).Data;
    4446      int minTimeOffset = GetVariableValue<IntData>("MinTimeOffset", scope, true).Data;
    4547      int conditionVariable = GetVariableValue<IntData>("ConditionVariable", scope, true).Data;
    4648
    47       int skippedSampels = 0;
     49      var rows = from row in Enumerable.Range(start, end - start)
     50                 // check if condition variable is true between sample - minTimeOffset and sample - maxTimeOffset
     51                 // => select rows where the value of the condition variable is different from zero in the whole range
     52                 where (from neighbour in Enumerable.Range(row + minTimeOffset, maxTimeOffset - minTimeOffset)
     53                        let value = dataset.GetValue(neighbour, conditionVariable)
     54                        where value == 0
     55                        select neighbour).Any() == false
     56                 select row;
     57
    4858      // store original and estimated values in a double array
    49       double[,] values = new double[end - start, 2];
    50       for (int sample = start; sample < end; sample++) {
    51         // check if condition variable is true between sample - minTimeOffset and sample - maxTimeOffset
    52         bool skip = false;
    53         for (int checkIndex = sample + minTimeOffset; checkIndex <= sample + maxTimeOffset && !skip; checkIndex++) {
    54           if (dataset.GetValue(checkIndex, conditionVariable) == 0) {
    55             skip = true;
    56             skippedSampels++;
    57           }
    58         }
    59         if (!skip) {
    60           double original = dataset.GetValue(sample, targetVariable);
    61           double estimated = evaluator.Evaluate(sample);
    62          
    63           values[sample - start - skippedSampels, 0] = estimated;
    64           values[sample - start - skippedSampels, 1] = original;
    65         }
    66       }
    67       //needed because otherwise the array is too large and therefore the sample count is incorrect during calculation
    68       ResizeArray(ref values, 2, end - start - skippedSampels);
    69 
     59      double[,] values = Matrix<double>.Create(
     60        evaluator.Evaluate(dataset, tree, rows).ToArray(),
     61        (from row in rows select dataset.GetValue(row, targetVariable)).ToArray());
    7062
    7163      // calculate quality value
     
    7870      }
    7971      qualityData.Data = quality;
    80       scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data -= skippedSampels;
    81     }
    82 
    83 
    84     private void ResizeArray(ref double[,] original, int cols, int rows) {
    85       double[,] newArray = new double[rows, cols];
    86       Array.Copy(original, newArray, cols * rows);
    87       original = newArray;
     72      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data -= (end - start) - rows.Count();
    8873    }
    8974
  • trunk/sources/HeuristicLab.GP.StructureIdentification.ConditionalEvaluation/3.3/ConditionalSimpleEvaluator.cs

    r2577 r2578  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.DataAnalysis;
     29using HeuristicLab.GP.Interfaces;
    2930
    3031namespace HeuristicLab.GP.StructureIdentification.ConditionalEvaluation {
     
    3839    }
    3940
    40     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
     41    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
    4142      ItemList values = GetVariableValue<ItemList>("Values", scope, false, false);
    4243      if (values == null) {
     
    5354      int minTimeOffset = GetVariableValue<IntData>("MinTimeOffset", scope, true).Data;
    5455      int conditionVariable = GetVariableValue<IntData>("ConditionVariable", scope, true).Data;
    55       int skippedSampels = 0;
    5656
    57       for (int sample = start; sample < end; sample++) {
    58         // check if condition variable is true between sample - minTimeOffset and sample - maxTimeOffset
    59         bool skip = false;
    60         for (int checkIndex = sample + minTimeOffset; checkIndex <= sample + maxTimeOffset && !skip ; checkIndex++) {
    61           if (dataset.GetValue(checkIndex, conditionVariable) == 0) {
    62             skip = true;
    63             skippedSampels++;
    64           }
    65         }
    66         if (!skip) {
    67           ItemList row = new ItemList();
    68           double estimated = evaluator.Evaluate(sample);
    69           double original = dataset.GetValue(sample, targetVariable);
    70          
    71           row.Add(new DoubleData(estimated));
    72           row.Add(new DoubleData(original));
    73           values.Add(row);
    74         }
     57      var rows = from row in Enumerable.Range(start, end - start)
     58                 // check if condition variable is true between sample - minTimeOffset and sample - maxTimeOffset
     59                 // => select rows where the value of the condition variable is different from zero in the whole range
     60                 where (from neighbour in Enumerable.Range(row + minTimeOffset, maxTimeOffset - minTimeOffset)
     61                        let value = dataset.GetValue(neighbour, conditionVariable)
     62                        where value == 0
     63                        select neighbour).Any() == false
     64                 select row;
     65
     66
     67      double[] estimatedValues = evaluator.Evaluate(dataset, tree, rows).ToArray();
     68      double[] originalValues = (from row in rows select dataset.GetValue(row, targetVariable)).ToArray();
     69      for (int i = 0; i < rows.Count(); i++) {
     70        ItemList row = new ItemList();
     71        row.Add(new DoubleData(estimatedValues[i]));
     72        row.Add(new DoubleData(originalValues[i]));
     73        values.Add(row);
    7574      }
    76       scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data -= skippedSampels;
     75
     76      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data -= (end - start) - rows.Count();
    7777    }
    7878  }
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/AveragePercentageChangeEvaluator.cs

    r2577 r2578  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Data;
     25using HeuristicLab.GP.Interfaces;
     26using HeuristicLab.DataAnalysis;
     27using System.Linq;
    2528
    2629namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
     
    3841    }
    3942
    40     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) {
     43    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
    4144      bool differential = GetVariableValue<BoolData>("Differential", scope, true).Data;
    4245      DoubleData apc = GetVariableValue<DoubleData>("APC", scope, false, false);
     
    4750
    4851      double percentageSum = 0;
    49       for (int sample = start; sample < end; sample++) {
     52      double[] estimatedValues = evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray();
     53      double[] originalValues = dataset.GetVariableValues(targetVariable, start - 1, end);
     54      for (int i = 0; i < estimatedValues.Length; i++) {
    5055        double prevOriginal;
    5156        double originalPercentageChange;
    5257        double estimatedPercentageChange;
    5358        if (differential) {
    54           prevOriginal = dataset.GetValue(sample - 1, targetVariable);
    55           originalPercentageChange = (dataset.GetValue(sample, targetVariable) - prevOriginal) / prevOriginal;
    56           estimatedPercentageChange = (evaluator.Evaluate(sample) - prevOriginal) / prevOriginal;
    57          
     59          prevOriginal = originalValues[i];
     60          originalPercentageChange = (originalValues[i + 1] - prevOriginal) / prevOriginal;
     61          estimatedPercentageChange = (estimatedValues[i] - prevOriginal) / prevOriginal;
     62
    5863        } else {
    59           originalPercentageChange = dataset.GetValue(sample, targetVariable);
    60           estimatedPercentageChange = evaluator.Evaluate(sample);
    61          
     64          originalPercentageChange = originalValues[i + 1];
     65          estimatedPercentageChange = estimatedValues[i];
     66
    6267        }
    6368        if (!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/ProfitEvaluator.cs

    r2577 r2578  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Data;
     24using HeuristicLab.GP.Interfaces;
     25using HeuristicLab.DataAnalysis;
     26using System.Linq;
    2427
    2528namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
     
    3841    }
    3942
    40     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) {
     43    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
    4144      int exchangeRateVarIndex = GetVariableValue<IntData>("ExchangeRate", scope, true).Data;
    4245      double transactionCost = GetVariableValue<DoubleData>("TransactionCost", scope, true).Data;
     
    5053      double cB = 0;
    5154      double exchangeRate = double.MaxValue;
    52       for (int sample = start; sample < end; sample++) {
    53         exchangeRate = dataset.GetValue(sample, exchangeRateVarIndex);
    54         double originalPercentageChange = dataset.GetValue(sample, targetVariable);
    55         double estimatedPercentageChange = evaluator.Evaluate(sample);
    56        
     55      double[] estimatedValues = evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray();
     56      double[] originalValues = dataset.GetVariableValues(targetVariable, start, end);
     57      double[] exchangeRateValues = dataset.GetVariableValues(exchangeRateVarIndex, start, end);
     58      for (int i = 0; i < estimatedValues.Length; i++) {
     59        exchangeRate = exchangeRateValues[i];
     60        double originalPercentageChange = originalValues[i];
     61        double estimatedPercentageChange = estimatedValues[i];
     62
    5763        if (!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
    5864          if (estimatedPercentageChange > 0) {
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/BaseClasses/TreeEvaluatorBase.cs

    r2364 r2578  
    6060    }
    6161
    62     public void PrepareForEvaluation(Dataset dataset, IFunctionTree functionTree) {
     62    [Obsolete]
     63    public virtual void PrepareForEvaluation(Dataset dataset, IFunctionTree functionTree) {
    6364      this.dataset = dataset;
    6465      codeArr = new Instr[functionTree.GetSize()];
     
    9495    }
    9596
    96     public double Evaluate(int sampleIndex) {
     97    [Obsolete]
     98    public virtual double Evaluate(int sampleIndex) {
    9799      PC = 0;
    98100      this.sampleIndex = sampleIndex;
     
    101103      if (double.IsNaN(estimated)) estimated = UpperEvaluationLimit;
    102104      return estimated;
     105    }
     106
     107    public virtual IEnumerable<double> Evaluate(Dataset dataset, IFunctionTree tree, IEnumerable<int> rows) {
     108      PrepareForEvaluation(dataset, tree);
     109      foreach (int row in rows)
     110        yield return Evaluate(row);
    103111    }
    104112
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs

    r2577 r2578  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Data;
     24using System;
     25using HeuristicLab.GP.Interfaces;
     26using HeuristicLab.DataAnalysis;
     27using System.Collections;
     28using System.Collections.Generic;
     29using System.Linq;
    2430
    2531namespace HeuristicLab.GP.StructureIdentification {
     
    3945
    4046    // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE
    41     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) {
     47    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
    4248      double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, true).Data;
    4349      DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false);
     
    4652        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse));
    4753      }
    48 
    4954      double errorsSquaredSum = 0;
    5055      int rows = end - start;
    5156      int n = 0;
    52       for (int sample = start; sample < end; sample++) {
    53         double estimated = evaluator.Evaluate(sample);
     57      int sample = start;
     58      foreach (var estimatedValue in evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start))) {
    5459        double original = dataset.GetValue(sample, targetVariable);
    55        
     60
    5661        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
    57           double error = estimated - original;
     62          double error = estimatedValue - original;
    5863          errorsSquaredSum += error * error;
    5964          n++;
    6065        }
    61         // check the limit and stop as soon as we hit the limit
    62         if (errorsSquaredSum / rows >= qualityLimit) {
     66        // check the limit every 30 samples and stop as soon as we hit the limit
     67        if (n % 30 == 29 && errorsSquaredSum / rows >= qualityLimit) {
    6368          mse.Data = errorsSquaredSum / (n + 1); // return estimated MSE (when the remaining errors are on average the same)
    6469          return;
    6570        }
     71        sample++;
    6672      }
    6773      errorsSquaredSum /= n;
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs

    r2577 r2578  
    4646      int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data;
    4747      int end = GetVariableValue<IntData>("SamplesEnd", scope, true).Data;
     48
    4849      ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true);
    49      
    50       evaluator.PrepareForEvaluation(dataset, gpModel.FunctionTree);
    51       Evaluate(scope, evaluator, dataset, targetVariable, start, end);
     50      Evaluate(scope, gpModel.FunctionTree, evaluator, dataset, targetVariable, start, end);
    5251
    5352      // update the value of total evaluated nodes
     
    5655    }
    5756
    58     public abstract void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end);
     57    public abstract void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end);
    5958  }
    6059}
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/NodeBasedVariableImpactCalculator.cs

    r2454 r2578  
    138138
    139139    private static double CalculateMSE(Dataset dataset, ITreeEvaluator evaluator, IFunctionTree tree, int targetVariable, int start, int end) {
    140       double[,] values = new double[end - start, 2];
    141       evaluator.PrepareForEvaluation(dataset, tree);
    142       for (int i = start; i < end; i++) {
    143         values[i - start, 0] = dataset.GetValue(i, targetVariable);
    144         values[i - start, 1] = evaluator.Evaluate(i);
    145       }
     140
     141      double[,] values = Matrix<double>.Create(
     142        dataset.GetVariableValues(targetVariable, start, end),
     143        evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray());
    146144      return SimpleMSEEvaluator.Calculate(values);
    147145    }
     
    155153
    156154    private static double CalculateReplacementValue(Dataset dataset, ITreeEvaluator evaluator, IFunctionTree tree, int targetVariable, int start, int end) {
    157       double[] values = new double[end - start];
    158       evaluator.PrepareForEvaluation(dataset, tree);
    159       for (int i = start; i < end; i++) {
    160         values[i - start] = evaluator.Evaluate(i);
    161       }
    162       return Statistics.Median(values);
     155      return Statistics.Median(evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray());
    163156    }
    164157
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleEvaluator.cs

    r2577 r2578  
    2323using HeuristicLab.Data;
    2424using HeuristicLab.DataAnalysis;
     25using HeuristicLab.GP.Interfaces;
     26using HeuristicLab.Modeling;
     27using System.Linq;
    2528
    2629namespace HeuristicLab.GP.StructureIdentification {
     
    3134    }
    3235
    33     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
     36    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
    3437      DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, false, false);
    3538      if (values == null) {
     
    4245      }
    4346
    44       double[,] v = new double[end - start, 2];
    45 
    46       for (int sample = start; sample < end; sample++) {
    47         double estimated = evaluator.Evaluate(sample);
    48         double original = dataset.GetValue(sample, targetVariable);
    49        
    50         v[sample - start, 0] = original;
    51         v[sample - start, 1] = estimated;
    52       }
     47      double[,] v = Matrix<double>.Create(
     48        dataset.GetVariableValues(targetVariable, start, end),
     49        evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray());
    5350      values.Data = v;
    5451    }
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleGPEvaluatorBase.cs

    r2577 r2578  
    2323using HeuristicLab.Data;
    2424using HeuristicLab.DataAnalysis;
     25using HeuristicLab.Modeling;
     26using HeuristicLab.GP.Interfaces;
     27using System.Linq;
    2528
    2629namespace HeuristicLab.GP.StructureIdentification {
     
    3336    }
    3437
    35     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
     38    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
    3639      // store original and estimated values in a double array
    37       double[,] values = new double[end - start, 2];
    38       for (int sample = start; sample < end; sample++) {
    39         double original = dataset.GetValue(sample, targetVariable);
    40         double estimated = evaluator.Evaluate(sample);
    41        
    42         values[sample - start, 0] = estimated;
    43         values[sample - start, 1] = original;
    44       }
     40      double[,] values = Matrix<double>.Create(
     41        dataset.GetVariableValues(targetVariable, start, end),
     42        evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray());
    4543
    4644      double quality = Evaluate(values);
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/UncertainMeanSquaredErrorEvaluator.cs

    r2577 r2578  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Random;
     26using HeuristicLab.GP.Interfaces;
     27using System.Collections.Generic;
     28using System.Linq;
    2629
    2730namespace HeuristicLab.GP.StructureIdentification {
     
    4548
    4649    // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE
    47     public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) {
     50    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) {
    4851      double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, true).Data;
    4952      int minSamples = GetVariableValue<IntData>("MinEvaluatedSamples", scope, true).Data;
     
    7275      int[] indexes = InitIndexes(mt, start, end);
    7376      int n = 0;
    74       for (int sample = 0; sample < rows; sample++) {
    75         double estimated = evaluator.Evaluate(indexes[sample]);
     77      int sample = 0;
     78      foreach (double estimated in evaluator.Evaluate(dataset, tree, indexes)) {
    7679        double original = dataset.GetValue(indexes[sample], targetVariable);
    7780        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
     
    9194          }
    9295        }
     96        sample++;
    9397      }
    9498
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HL2TreeEvaluator.cs

    r2328 r2578  
    3131    public HL2TreeEvaluator(double minValue, double maxValue) : base(minValue, maxValue) { }
    3232
     33    [Obsolete]
    3334    protected override double EvaluateBakedCode() {
    3435      Instr currInstr = codeArr[PC++];
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HL3TreeEvaluator.cs

    r2449 r2578  
    3333    public HL3TreeEvaluator(double minValue, double maxValue) : base(minValue, maxValue) { }
    3434
     35    [Obsolete]
    3536    protected override double EvaluateBakedCode() {
    3637      Instr currInstr = codeArr[PC++];
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/ITreeEvaluator.cs

    r2328 r2578  
    2323using HeuristicLab.DataAnalysis;
    2424using HeuristicLab.GP.Interfaces;
     25using System;
     26using System.Collections.Generic;
    2527
    2628namespace HeuristicLab.GP.StructureIdentification {
     
    2830    double LowerEvaluationLimit { get; set; }
    2931    double UpperEvaluationLimit { get; set; }
     32    [Obsolete]
    3033    void PrepareForEvaluation(Dataset dataset, IFunctionTree functionTree);
     34    [Obsolete]
    3135    double Evaluate(int sampleIndex);
     36    IEnumerable<double> Evaluate(Dataset dataset, IFunctionTree functionTree, IEnumerable<int> rows);
    3237  }
    3338}
Note: See TracChangeset for help on using the changeset viewer.