- Timestamp:
- 08/14/12 13:59:47 (12 years ago)
- 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 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 65 66 int row = rowsEnumerator.Current; 66 67 int horizon = horizonsEnumerator.Current; 68 if (row - TimeOffset < 0) { 69 yield return Enumerable.Repeat(double.NaN, horizon); 70 continue; 71 } 72 67 73 double[] prognosis = new double[horizon]; 68 69 74 for (int h = 0; h < horizon; h++) { 70 75 double estimatedValue = 0.0; 71 for (int i = 1; i < TimeOffset; i++) {76 for (int i = 1; i <= TimeOffset; i++) { 72 77 int offset = h - i; 73 78 if (offset >= 0) estimatedValue += prognosis[offset] * Phi[i - 1]; … … 90 95 foreach (int row in rows) { 91 96 double estimatedValue = 0.0; 97 if (row - TimeOffset < 0) { 98 yield return double.NaN; 99 continue; 100 } 101 92 102 for (int i = 1; i <= TimeOffset; i++) { 93 103 estimatedValue += targetVariables[row - i] * Phi[i - 1]; -
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) { -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs
r8477 r8486 1578 1578 } 1579 1579 1580 public TimeSeriesPrognosisProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) { } 1580 public TimeSeriesPrognosisProblemData() 1581 : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) { 1582 TrainingPartition.Start = 50; 1583 } 1581 1584 public TimeSeriesPrognosisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable) 1582 1585 : base(dataset, allowedInputVariables, targetVariable) { … … 1587 1590 TestHorizonParameter.Hidden = true; 1588 1591 1592 TrainingPartition.Start = Math.Min((int)(TrainingPartition.Size * 0.2), 50); 1593 1589 1594 RegisterParameterEventHandlers(); 1590 1595 }
Note: See TracChangeset
for help on using the changeset viewer.