Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/10/10 21:01:03 (15 years ago)
Author:
gkronber
Message:

Implemented #834 (IPredictor.Predict() should return an IEnumerable<double> instead of an double[]).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Predictor.cs

    r2567 r2619  
    2929using System.Xml;
    3030using HeuristicLab.DataAnalysis;
     31using System.Linq;
    3132
    3233namespace HeuristicLab.GP.StructureIdentification {
     
    5051    }
    5152
    52     public override double[] Predict(Dataset input, int start, int end) {
     53    public override IEnumerable<double> Predict(Dataset input, int start, int end) {
    5354      treeEvaluator.UpperEvaluationLimit = UpperPredictionLimit;
    5455      treeEvaluator.LowerEvaluationLimit = LowerPredictionLimit;
     
    5657      if (start < 0 || end <= start) throw new ArgumentException("start must be larger than zero and strictly smaller than end");
    5758      if (end > input.Rows) throw new ArgumentOutOfRangeException("number of rows in input is smaller then end");
    58       treeEvaluator.PrepareForEvaluation(input, functionTree.FunctionTree);
    59       double[] result = new double[end - start];
    60       for (int i = 0; i < result.Length; i++) {
    61         try {
    62           result[i] = treeEvaluator.Evaluate(i + start);
    63         }
    64         catch (ArgumentException) {
    65           result[i] = double.NaN;
    66         }
    67       }
    68       return result;
     59      return treeEvaluator.Evaluate(input, functionTree.FunctionTree, Enumerable.Range(start, end - start));
    6960    }
    7061
Note: See TracChangeset for help on using the changeset viewer.