Changeset 8764
- Timestamp:
- 10/09/12 12:01:53 (12 years ago)
- Location:
- branches/HeuristicLab.TimeSeries
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionErrorCharacteristicsCurveView.cs
r8487 r8764 50 50 base.UpdateChart(); 51 51 if (Content == null) return; 52 var movingAverageModel = new TimeSeriesPrognosisMovingAverageModel(10, Content.ProblemData.TargetVariable).CreateTimeSeriesPrognosisSolution(ProblemData);53 movingAverageModel.Name = "Moving average Model";54 AddRegressionSolution(movingAverageModel);55 52 56 53 //AR1 model -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r8750 r8764 149 149 <Compile Include="Implementation\Regression\RegressionEnsembleSolution.cs" /> 150 150 <Compile Include="Implementation\TimeSeriesPrognosis\Models\ConstantTimeSeriesPrognosisModel.cs" /> 151 <Compile Include="Implementation\TimeSeriesPrognosis\Models\TimeSeriesPrognosisMovingAverageModel.cs" />152 151 <Compile Include="Implementation\TimeSeriesPrognosis\Models\TimeSeriesPrognosisAutoRegressiveModel.cs" /> 153 152 <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisProblem.cs" /> -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisResults.cs
r8762 r8764 55 55 protected const string PrognosisTrainingTheilsUStatisticMeanResultName = "Theil's U2 (mean) (training)"; 56 56 protected const string PrognosisTestTheilsUStatisticMeanResultName = "Theil's U2 (mean) (test)"; 57 protected const string PrognosisTrainingTheilsUStatisticMovingAverageResultName = "Theil's U2 (moving average) (training)";58 protected const string PrognosisTestTheilsUStatisticMovingAverageResultName = "Theil's U2 (moving average) (test)";59 57 #endregion 60 58 … … 81 79 protected const string PrognosisTrainingTheilsUStatisticMeanResultDescription = "The Theil's U statistic (reference: mean model) of the forecasts of the model on the training partition"; 82 80 protected const string PrognosisTestTheilsUStatisticMeanResultDescription = "The Theil's U statistic (reference: mean value) of the forecasts of the model on the test partition"; 83 protected const string PrognosisTrainingTheilsUStatisticMovingAverageResultDescription = "The Theil's U statistic (reference: moving average model) of the forecasts of the model on the training partition";84 protected const string PrognosisTestTheilsUStatisticMovingAverageResultDescription = "The Theil's U statistic (reference: moving average model) of the forecasts of the model on the test partition";85 81 #endregion 86 82 … … 298 294 if (!ContainsKey(PrognosisTestTheilsUStatisticMeanResultName)) Add(new Result(PrognosisTestTheilsUStatisticMeanResultName, PrognosisTestTheilsUStatisticMeanResultDescription, new DoubleValue())); 299 295 ((DoubleValue)this[PrognosisTestTheilsUStatisticMeanResultName].Value).Value = value; 300 }301 }302 public double PrognosisTrainingTheilsUStatisticMovingAverage {303 get {304 if (!ContainsKey(PrognosisTrainingTheilsUStatisticMovingAverageResultName)) return double.NaN;305 return ((DoubleValue)this[PrognosisTrainingTheilsUStatisticMovingAverageResultName].Value).Value;306 }307 private set {308 if (!ContainsKey(PrognosisTrainingTheilsUStatisticMovingAverageResultName)) Add(new Result(PrognosisTrainingTheilsUStatisticMovingAverageResultName, PrognosisTrainingTheilsUStatisticMovingAverageResultDescription, new DoubleValue()));309 ((DoubleValue)this[PrognosisTrainingTheilsUStatisticMovingAverageResultName].Value).Value = value;310 }311 }312 public double PrognosisTestTheilsUStatisticMovingAverage {313 get {314 if (!ContainsKey(PrognosisTestTheilsUStatisticMovingAverageResultName)) return double.NaN;315 return ((DoubleValue)this[PrognosisTestTheilsUStatisticMovingAverageResultName].Value).Value;316 }317 private set {318 if (!ContainsKey(PrognosisTestTheilsUStatisticMovingAverageResultName)) Add(new Result(PrognosisTestTheilsUStatisticMovingAverageResultName, PrognosisTestTheilsUStatisticMovingAverageResultDescription, new DoubleValue()));319 ((DoubleValue)this[PrognosisTestTheilsUStatisticMovingAverageResultName].Value).Value = value;320 296 } 321 297 } … … 399 375 var AR1model = new TimeSeriesPrognosisAutoRegressiveModel(problemData.TargetVariable, new double[] { beta }, alpha); 400 376 401 //MA model402 const int movingAverageWindowSize = 10;403 var MovingAverageModel = new TimeSeriesPrognosisMovingAverageModel(movingAverageWindowSize, problemData.TargetVariable);404 405 377 var trainingHorizions = problemData.TrainingIndices.Select(r => Math.Min(trainingHorizon, problemData.TrainingPartition.End - r)).ToList(); 406 378 IEnumerable<IEnumerable<double>> trainingTargetValues = problemData.TrainingIndices.Zip(trainingHorizions, Enumerable.Range).Select(r => problemData.Dataset.GetDoubleValues(problemData.TargetVariable, r)).ToList(); … … 408 380 IEnumerable<IEnumerable<double>> trainingMeanModelPredictions = meanModel.GetPrognosedValues(problemData.Dataset, problemData.TrainingIndices, trainingHorizions).ToList(); 409 381 IEnumerable<IEnumerable<double>> trainingAR1ModelPredictions = AR1model.GetPrognosedValues(problemData.Dataset, problemData.TrainingIndices, trainingHorizions).ToList(); 410 IEnumerable<IEnumerable<double>> trainingMovingAverageModelPredictions = MovingAverageModel.GetPrognosedValues(problemData.Dataset, problemData.TrainingIndices, trainingHorizions).ToList();411 382 412 383 IEnumerable<double> originalTrainingValues = trainingTargetValues.SelectMany(x => x).ToList(); … … 434 405 PrognosisTrainingTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(trainingStartValues, trainingTargetValues, trainingMeanModelPredictions, trainingEstimatedValues, out errorState); 435 406 PrognosisTrainingTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? PrognosisTrainingTheilsUStatisticMean : double.PositiveInfinity; 436 PrognosisTrainingTheilsUStatisticMovingAverage = OnlineTheilsUStatisticCalculator.Calculate(trainingStartValues, trainingTargetValues, trainingMovingAverageModelPredictions, trainingEstimatedValues, out errorState);437 PrognosisTrainingTheilsUStatisticMovingAverage = errorState == OnlineCalculatorError.None ? PrognosisTrainingTheilsUStatisticMovingAverage : double.PositiveInfinity;438 407 } 439 408 … … 452 421 var AR1model = new TimeSeriesPrognosisAutoRegressiveModel(problemData.TargetVariable, new double[] { beta }, alpha); 453 422 454 //MA model455 const int movingAverageWindowSize = 10;456 var MovingAverageModel = new TimeSeriesPrognosisMovingAverageModel(movingAverageWindowSize, problemData.TargetVariable);457 458 423 var testHorizions = problemData.TestIndices.Select(r => Math.Min(testHorizon, problemData.TestPartition.End - r)).ToList(); 459 424 IEnumerable<IEnumerable<double>> testTargetValues = problemData.TestIndices.Zip(testHorizions, Enumerable.Range).Select(r => problemData.Dataset.GetDoubleValues(problemData.TargetVariable, r)).ToList(); … … 462 427 IEnumerable<IEnumerable<double>> testMeanModelPredictions = meanModel.GetPrognosedValues(problemData.Dataset, problemData.TestIndices, testHorizions).ToList(); 463 428 IEnumerable<IEnumerable<double>> testAR1ModelPredictions = AR1model.GetPrognosedValues(problemData.Dataset, problemData.TestIndices, testHorizions).ToList(); 464 IEnumerable<IEnumerable<double>> testMovingAverageModelPredictions = MovingAverageModel.GetPrognosedValues(problemData.Dataset, problemData.TestIndices, testHorizions).ToList();465 429 466 430 IEnumerable<double> originalTestValues = testTargetValues.SelectMany(x => x).ToList(); … … 488 452 PrognosisTestTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(testStartValues, testTargetValues, testMeanModelPredictions, testEstimatedValues, out errorState); 489 453 PrognosisTestTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? PrognosisTestTheilsUStatisticMean : double.PositiveInfinity; 490 PrognosisTestTheilsUStatisticMovingAverage = OnlineTheilsUStatisticCalculator.Calculate(testStartValues, testTargetValues, testMovingAverageModelPredictions, testEstimatedValues, out errorState);491 PrognosisTestTheilsUStatisticMovingAverage = errorState == OnlineCalculatorError.None ? PrognosisTestTheilsUStatisticMovingAverage : double.PositiveInfinity;492 454 } 493 455 } -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs
r8750 r8764 39 39 protected const string TrainingTheilsUStatisticMeanResultName = "Theil's U2 (mean) (training)"; 40 40 protected const string TestTheilsUStatisticMeanResultName = "Theil's U2 (mean) (test)"; 41 protected const string TrainingTheilsUStatisticMovingAverageResultName = "Theil's U2 (moving average) (training)";42 protected const string TestTheilsUStatisticMovingAverageResultName = "Theil's U2 (moving average) (test)";43 41 protected const string TimeSeriesPrognosisResultName = "Prognosis Results"; 44 42 #endregion … … 53 51 protected const string TrainingTheilsUStatisticMeanResultDescription = "The Theil's U statistic (reference: mean model) of the forecasts of the model on the training partition"; 54 52 protected const string TestTheilsUStatisticMeanResultDescription = "The Theil's U statistic (reference: mean value) of the forecasts of the model on the test partition"; 55 protected const string TrainingTheilsUStatisticMovingAverageResultDescription = "The Theil's U statistic (reference: moving average model) of the forecasts of the model on the training partition";56 protected const string TestTheilsUStatisticMovingAverageResultDescription = "The Theil's U statistic (reference: moving average model) of the forecasts of the model on the test partition";57 53 protected const string TimeSeriesPrognosisResultDescription = "The calculated results of predictions in the future."; 58 54 #endregion … … 103 99 private set { ((DoubleValue)this[TestTheilsUStatisticMeanResultName].Value).Value = value; } 104 100 } 105 public double TrainingTheilsUStatisticMovingAverage {106 get { return ((DoubleValue)this[TrainingTheilsUStatisticMovingAverageResultName].Value).Value; }107 private set { ((DoubleValue)this[TrainingTheilsUStatisticMovingAverageResultName].Value).Value = value; }108 }109 public double TestTheilsUStatisticMovingAverage {110 get { return ((DoubleValue)this[TestTheilsUStatisticMovingAverageResultName].Value).Value; }111 private set { ((DoubleValue)this[TestTheilsUStatisticMovingAverageResultName].Value).Value = value; }112 }113 101 114 102 public TimeSeriesPrognosisResults TimeSeriesPrognosisResults { … … 151 139 Add(new Result(TrainingTheilsUStatisticMeanResultName, TrainingTheilsUStatisticMeanResultDescription, new DoubleValue())); 152 140 Add(new Result(TestTheilsUStatisticMeanResultName, TestTheilsUStatisticMeanResultDescription, new DoubleValue())); 153 Add(new Result(TrainingTheilsUStatisticMovingAverageResultName, TrainingTheilsUStatisticMovingAverageResultDescription, new DoubleValue()));154 Add(new Result(TestTheilsUStatisticMovingAverageResultName, TestTheilsUStatisticMovingAverageResultDescription, new DoubleValue()));155 141 } 156 142 … … 171 157 var AR1model = new TimeSeriesPrognosisAutoRegressiveModel(ProblemData.TargetVariable, new double[] { beta }, alpha); 172 158 173 //MA model174 const int movingAverageWindowSize = 10;175 var movingAverageModel = new TimeSeriesPrognosisMovingAverageModel(movingAverageWindowSize, ProblemData.TargetVariable);176 159 177 160 #region Calculate training quality measures … … 180 163 IEnumerable<double> trainingMeanModelPredictions = meanModel.GetEstimatedValues(ProblemData.Dataset, ProblemData.TrainingIndices).ToList(); 181 164 IEnumerable<double> trainingAR1ModelPredictions = AR1model.GetEstimatedValues(ProblemData.Dataset, ProblemData.TrainingIndices).ToList(); 182 IEnumerable<double> trainingMovingAverageModelPredictions = movingAverageModel.GetEstimatedValues(ProblemData.Dataset, ProblemData.TrainingIndices).ToList();183 165 184 166 TrainingDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingEstimatedValues, out errorState); … … 190 172 TrainingTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingMeanModelPredictions, trainingEstimatedValues, out errorState); 191 173 TrainingTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? TrainingTheilsUStatisticMean : double.PositiveInfinity; 192 TrainingTheilsUStatisticMovingAverage = OnlineTheilsUStatisticCalculator.Calculate(trainingTargetValues.First(), trainingTargetValues, trainingMovingAverageModelPredictions, trainingEstimatedValues, out errorState);193 TrainingTheilsUStatisticMovingAverage = errorState == OnlineCalculatorError.None ? TrainingTheilsUStatisticMovingAverage : double.PositiveInfinity;194 174 #endregion 195 175 … … 199 179 IEnumerable<double> testMeanModelPredictions = meanModel.GetEstimatedValues(ProblemData.Dataset, ProblemData.TestIndices).ToList(); 200 180 IEnumerable<double> testAR1ModelPredictions = AR1model.GetEstimatedValues(ProblemData.Dataset, ProblemData.TestIndices).ToList(); 201 IEnumerable<double> testMovingAverageModelPredictions = movingAverageModel.GetEstimatedValues(ProblemData.Dataset, ProblemData.TestIndices).ToList();202 181 203 182 TestDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate(testTargetValues.First(), testTargetValues, testEstimatedValues, out errorState); … … 209 188 TestTheilsUStatisticMean = OnlineTheilsUStatisticCalculator.Calculate(testTargetValues.First(), testTargetValues, testMeanModelPredictions, testEstimatedValues, out errorState); 210 189 TestTheilsUStatisticMean = errorState == OnlineCalculatorError.None ? TestTheilsUStatisticMean : double.PositiveInfinity; 211 TestTheilsUStatisticMovingAverage = OnlineTheilsUStatisticCalculator.Calculate(testTargetValues.First(), testTargetValues, testMovingAverageModelPredictions, testEstimatedValues, out errorState);212 TestTheilsUStatisticMovingAverage = errorState == OnlineCalculatorError.None ? TestTheilsUStatisticMovingAverage : double.PositiveInfinity;213 190 #endregion 214 191 }
Note: See TracChangeset
for help on using the changeset viewer.