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.

Location:
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis
Files:
3 edited

Legend:

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

    r8468 r8486  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    6566        int row = rowsEnumerator.Current;
    6667        int horizon = horizonsEnumerator.Current;
     68        if (row - TimeOffset < 0) {
     69          yield return Enumerable.Repeat(double.NaN, horizon);
     70          continue;
     71        }
     72
    6773        double[] prognosis = new double[horizon];
    68 
    6974        for (int h = 0; h < horizon; h++) {
    7075          double estimatedValue = 0.0;
    71           for (int i = 1; i < TimeOffset; i++) {
     76          for (int i = 1; i <= TimeOffset; i++) {
    7277            int offset = h - i;
    7378            if (offset >= 0) estimatedValue += prognosis[offset] * Phi[i - 1];
     
    9095      foreach (int row in rows) {
    9196        double estimatedValue = 0.0;
     97        if (row - TimeOffset < 0) {
     98          yield return double.NaN;
     99          continue;
     100        }
     101
    92102        for (int i = 1; i <= TimeOffset; i++) {
    93103          estimatedValue += targetVariables[row - i] * Phi[i - 1];
  • 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) {
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs

    r8477 r8486  
    15781578    }
    15791579
    1580     public TimeSeriesPrognosisProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) { }
     1580    public TimeSeriesPrognosisProblemData()
     1581      : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) {
     1582      TrainingPartition.Start = 50;
     1583    }
    15811584    public TimeSeriesPrognosisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
    15821585      : base(dataset, allowedInputVariables, targetVariable) {
     
    15871590      TestHorizonParameter.Hidden = true;
    15881591
     1592      TrainingPartition.Start = Math.Min((int)(TrainingPartition.Size * 0.2), 50);
     1593
    15891594      RegisterParameterEventHandlers();
    15901595    }
Note: See TracChangeset for help on using the changeset viewer.