Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/28/08 18:46:02 (16 years ago)
Author:
gkronber
Message:

fixed ticket #205 by creating the function-specific evaluator in the evaluation operators.

Location:
trunk/sources/HeuristicLab.StructureIdentification/Evaluation
Files:
9 edited

Legend:

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

    r367 r396  
    4949      double originalDeviationTotalSumOfSquares = 0.0;
    5050      double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    51       functionTree.PrepareEvaluation(dataset);
    5251      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    53         double estimated = functionTree.Evaluate(sample);
     52        double estimated = evaluator.Evaluate(sample);
    5453        double original = dataset.GetValue(sample, targetVariable);
    5554        if(!double.IsNaN(original) && !double.IsInfinity(original)) {
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/EarlyStoppingMeanSquaredErrorEvaluator.cs

    r367 r396  
    6060      double errorsSquaredSum = 0;
    6161      double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    62       functionTree.PrepareEvaluation(dataset);
    6362      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    64         double estimated = functionTree.Evaluate(sample);
     63        double estimated = evaluator.Evaluate(sample);
    6564        double original = dataset.GetValue(sample, targetVariable);
    6665        if(double.IsNaN(estimated) || double.IsInfinity(estimated)) {
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/GPEvaluatorBase.cs

    r363 r396  
    3535    protected int treeSize;
    3636    protected double totalEvaluatedNodes;
     37    protected IEvaluator evaluator;
    3738
    3839    public GPEvaluatorBase()
     
    5657      this.treeSize = scope.GetVariableValue<IntData>("TreeSize", false).Data;
    5758      this.totalEvaluatedNodes = scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data;
     59      if(evaluator == null) evaluator = functionTree.CreateEvaluator(dataset);
     60      evaluator.ResetEvaluator(functionTree);
    5861      double result = Evaluate(scope, functionTree, targetVariable, dataset);
    5962
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MCCEvaluator.cs

    r367 r396  
    5858      double negative = 0;
    5959      double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    60       functionTree.PrepareEvaluation(dataset);
    6160      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    62         double est = functionTree.Evaluate(sample);
     61        double est = evaluator.Evaluate(sample);
    6362        double orig = dataset.GetValue(sample, targetVariable);
    6463        if(double.IsNaN(est) || double.IsInfinity(est)) {
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanAbsolutePercentageErrorEvaluator.cs

    r395 r396  
    4747      int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
    4848      double errorsSum = 0.0;
    49       functionTree.PrepareEvaluation(dataset);
    5049      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    51         double estimated = functionTree.Evaluate(sample);
     50        double estimated = evaluator.Evaluate(sample);
    5251        double original = dataset.GetValue(sample, targetVariable);
    5352        if(!double.IsNaN(original) && !double.IsInfinity(original)) {
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanSquaredErrorEvaluator.cs

    r367 r396  
    5959        }
    6060      }
    61 
    62       functionTree.PrepareEvaluation(dataset);
    6361      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    64         double estimated = functionTree.Evaluate(sample);
     62        double estimated = evaluator.Evaluate(sample);
    6563        double original = dataset.GetValue(sample, targetVariable);
    6664        if(double.IsNaN(estimated) || double.IsInfinity(estimated)) {
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/SimpleEvaluator.cs

    r363 r396  
    3434    protected int treeSize;
    3535    protected double totalEvaluatedNodes;
     36    private IEvaluator evaluator;
    3637
    3738    public SimpleEvaluator()
     
    6667      }
    6768      values.Clear();
    68       functionTree.PrepareEvaluation(dataset);
     69      if(evaluator == null) evaluator = functionTree.CreateEvaluator(dataset);
     70      evaluator.ResetEvaluator(functionTree);
    6971      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    7072        ItemList row = new ItemList();
    71         row.Add(new DoubleData(functionTree.Evaluate(sample)));
     73        row.Add(new DoubleData(evaluator.Evaluate(sample)));
    7274        row.Add(new DoubleData(dataset.GetValue(sample, targetVariable)));
    7375        values.Add(row);
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/TheilInequalityCoefficientEvaluator.cs

    r395 r396  
    5151      double estimatedSquaredSum = 0.0;
    5252      double originalSquaredSum = 0.0;
    53       functionTree.PrepareEvaluation(dataset);
    5453      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    5554        double prevValue = 0.0;
    5655        if(difference) prevValue = dataset.GetValue(sample - 1, targetVariable);
    57         double estimatedChange = functionTree.Evaluate(sample) - prevValue;
     56        double estimatedChange = evaluator.Evaluate(sample) - prevValue;
    5857        double originalChange = dataset.GetValue(sample, targetVariable) - prevValue;
    5958        if(!double.IsNaN(originalChange) && !double.IsInfinity(originalChange)) {
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/VarianceAccountedForEvaluator.cs

    r367 r396  
    5959      double[] originalTargetVariableValues = new double[trainingEnd-trainingStart];
    6060      double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd);
    61       functionTree.PrepareEvaluation(dataset);
    6261      for(int sample = trainingStart; sample < trainingEnd; sample++) {
    63         double estimated = functionTree.Evaluate(sample);
     62        double estimated = evaluator.Evaluate(sample);
    6463        double original = dataset.GetValue(sample, targetVariable);
    6564        if(!double.IsNaN(original) && !double.IsInfinity(original)) {
Note: See TracChangeset for help on using the changeset viewer.