Changeset 8486 for branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/Models/TimeSeriesPrognosisMovingAverageModel.cs
- Timestamp:
- 08/14/12 13:59:47 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/Models/TimeSeriesPrognosisMovingAverageModel.cs
r8468 r8486 60 60 int horizon = horizonsEnumerator.Current; 61 61 int startIndex = row - WindowSize; 62 if (startIndex < 0) { 63 yield return Enumerable.Repeat(double.NaN, horizon); 64 continue; 65 } 62 66 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(); 67 68 int position = 0; 68 69 for (int i = 0; i < horizon; i++) { 69 double prognosis = targetValues.GetRange(position, count).Average();70 double prognosis = targetValues.GetRange(position, WindowSize).Average(); 70 71 targetValues.Add(prognosis); 71 if (count < WindowSize) count++; 72 else position++; 72 position++; 73 73 } 74 74 yield return targetValues.GetRange(targetValues.Count - horizon, horizon); … … 80 80 81 81 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) {85 82 var targetValues = dataset.GetReadOnlyDoubleValues(TargetVariable).ToList(); 86 83 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(); 88 86 } 89 87 } 90 91 88 92 89 public ITimeSeriesPrognosisSolution CreateTimeSeriesPrognosisSolution(ITimeSeriesPrognosisProblemData problemData) {
Note: See TracChangeset
for help on using the changeset viewer.