Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/14/12 13:59:47 (12 years ago)
Author:
mkommend
Message:

#1081: Corrected evaluators and time series models.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/Models/TimeSeriesPrognosisMovingAverageModel.cs

    r8468 r8486  
    6060        int horizon = horizonsEnumerator.Current;
    6161        int startIndex = row - WindowSize;
     62        if (startIndex < 0) {
     63          yield return Enumerable.Repeat(double.NaN, horizon);
     64          continue;
     65        }
    6266
    63         if (startIndex < 0) startIndex = 0;
    64         int count = row - startIndex - 1;
    65 
    66         List<double> targetValues = dataset.GetDoubleValues(TargetVariable, Enumerable.Range(startIndex, count)).ToList();
     67        List<double> targetValues = dataset.GetDoubleValues(TargetVariable, Enumerable.Range(startIndex, WindowSize)).ToList();
    6768        int position = 0;
    6869        for (int i = 0; i < horizon; i++) {
    69           double prognosis = targetValues.GetRange(position, count).Average();
     70          double prognosis = targetValues.GetRange(position, WindowSize).Average();
    7071          targetValues.Add(prognosis);
    71           if (count < WindowSize) count++;
    72           else position++;
     72          position++;
    7373        }
    7474        yield return targetValues.GetRange(targetValues.Count - horizon, horizon);
     
    8080
    8181    public IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows) {
    82       return GetPrognosedValues(dataset, rows, rows.Select(r => 1)).SelectMany(e => e);
    83     }
    84     public IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows, int x) {
    8582      var targetValues = dataset.GetReadOnlyDoubleValues(TargetVariable).ToList();
    8683      foreach (int row in rows) {
    87         yield return targetValues.GetRange(row - WindowSize, WindowSize).Average();
     84        if (row - WindowSize < 0) yield return double.NaN;
     85        else yield return targetValues.GetRange(row - WindowSize, WindowSize).Average();
    8886      }
    8987    }
    90 
    9188
    9289    public ITimeSeriesPrognosisSolution CreateTimeSeriesPrognosisSolution(ITimeSeriesPrognosisProblemData problemData) {
Note: See TracChangeset for help on using the changeset viewer.