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
  • trunk/sources/HeuristicLab.SupportVectorMachines/3.2/Predictor.cs

    r2436 r2619  
    6666    }
    6767
    68     public override double[] Predict(Dataset input, int start, int end) {
     68    public override IEnumerable<double> Predict(Dataset input, int start, int end) {
    6969      if (start < 0 || end <= start) throw new ArgumentException("start must be larger than zero and strictly smaller than end");
    7070      if (end > input.Rows) throw new ArgumentOutOfRangeException("number of rows in input is smaller then end");
     
    7878      int targetVariableIndex = input.GetVariableIndex(targetVariable);
    7979      int rows = end - start;
    80       double[] result = new double[rows];
     80      //double[] result = new double[rows];
    8181      int problemRow = 0;
    8282      for (int resultRow = 0; resultRow < rows; resultRow++) {
    8383        if (double.IsNaN(input.GetValue(resultRow, targetVariableIndex)))
    84           result[resultRow] = UpperPredictionLimit;
     84          yield return UpperPredictionLimit;
    8585        else if (resultRow + maxTimeOffset < 0) {
    86           result[resultRow] = UpperPredictionLimit;
    8786          problemRow++;
     87          yield return UpperPredictionLimit;
    8888        } else {
    89           result[resultRow] = Math.Max(Math.Min(SVM.Prediction.Predict(model, scaledProblem.X[problemRow++]), UpperPredictionLimit), LowerPredictionLimit);
     89          yield return Math.Max(Math.Min(SVM.Prediction.Predict(model, scaledProblem.X[problemRow++]), UpperPredictionLimit), LowerPredictionLimit);
    9090        }
    9191      }
    92       return result;
    9392    }
    9493
Note: See TracChangeset for help on using the changeset viewer.