Changeset 7099 for branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis
- Timestamp:
- 11/29/11 19:52:22 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs
r6802 r7099 40 40 private const string TrainingNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (training)"; 41 41 private const string TestNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (test)"; 42 private const string TrainingDirectionalSymmetryResultName = " Directional symmetry (training)";43 private const string TestDirectionalSymmetryResultName = " Directional symmetry (test)";44 private const string TrainingWeightedDirectionalSymmetryResultName = " Weighted directional symmetry (training)";45 private const string TestWeightedDirectionalSymmetryResultName = " Weighted directional symmetry (test)";46 private const string TrainingTheilsUStatisticResultName = " Theil's U (training)";47 private const string TestTheilsUStatisticResultName = " Theil's U (test)";42 private const string TrainingDirectionalSymmetryResultName = "Average directional symmetry (training)"; 43 private const string TestDirectionalSymmetryResultName = "Average directional symmetry (test)"; 44 private const string TrainingWeightedDirectionalSymmetryResultName = "Average weighted directional symmetry (training)"; 45 private const string TestWeightedDirectionalSymmetryResultName = "Average weighted directional symmetry (test)"; 46 private const string TrainingTheilsUStatisticResultName = "Average Theil's U (training)"; 47 private const string TestTheilsUStatisticResultName = "Average Theil's U (test)"; 48 48 49 49 public new ITimeSeriesPrognosisModel Model { … … 146 146 Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the training partition", new DoubleValue())); 147 147 Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue())); 148 Add(new Result(TrainingDirectionalSymmetryResultName, "The directional symmetry of the output of the model on the training partition", new DoubleValue()));149 Add(new Result(TestDirectionalSymmetryResultName, "The directional symmetry of the output of the model on the test partition", new DoubleValue()));150 Add(new Result(TrainingWeightedDirectionalSymmetryResultName, "The weighted directional symmetry of the outputof the model on the training partition", new DoubleValue()));151 Add(new Result(TestWeightedDirectionalSymmetryResultName, "The weighted directional symmetry of the outputof the model on the test partition", new DoubleValue()));152 Add(new Result(TrainingTheilsUStatisticResultName, "The Theil's U statistic of the outputof the model on the training partition", new DoubleValue()));153 Add(new Result(TestTheilsUStatisticResultName, "The Theil's U statistic of the outputof the model on the test partition", new DoubleValue()));148 Add(new Result(TrainingDirectionalSymmetryResultName, "The average directional symmetry of the forecasts of the model on the training partition", new PercentValue())); 149 Add(new Result(TestDirectionalSymmetryResultName, "The average directional symmetry of the forecasts of the model on the test partition", new PercentValue())); 150 Add(new Result(TrainingWeightedDirectionalSymmetryResultName, "The average weighted directional symmetry of the forecasts of the model on the training partition", new DoubleValue())); 151 Add(new Result(TestWeightedDirectionalSymmetryResultName, "The average weighted directional symmetry of the forecasts of the model on the test partition", new DoubleValue())); 152 Add(new Result(TrainingTheilsUStatisticResultName, "The average Theil's U statistic of the forecasts of the model on the training partition", new DoubleValue())); 153 Add(new Result(TestTheilsUStatisticResultName, "The average Theil's U statistic of the forecasts of the model on the test partition", new DoubleValue())); 154 154 } 155 155 … … 166 166 167 167 OnlineCalculatorError errorState; 168 double trainingMse = OnlineMeanSquaredErrorCalculator.Calculate( estimatedTrainingValues, originalTrainingValues, out errorState);168 double trainingMse = OnlineMeanSquaredErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 169 169 TrainingMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingMse : double.NaN; 170 double testMse = OnlineMeanSquaredErrorCalculator.Calculate( estimatedTestValues, originalTestValues, out errorState);170 double testMse = OnlineMeanSquaredErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 171 171 TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMse : double.NaN; 172 172 173 double trainingMae = OnlineMeanAbsoluteErrorCalculator.Calculate( estimatedTrainingValues, originalTrainingValues, out errorState);173 double trainingMae = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 174 174 TrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMae : double.NaN; 175 double testMae = OnlineMeanAbsoluteErrorCalculator.Calculate( estimatedTestValues, originalTestValues, out errorState);175 double testMae = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 176 176 TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMae : double.NaN; 177 177 178 double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate( estimatedTrainingValues, originalTrainingValues, out errorState);178 double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 179 179 TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN; 180 double testR2 = OnlinePearsonsRSquaredCalculator.Calculate( estimatedTestValues, originalTestValues, out errorState);180 double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 181 181 TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN; 182 182 183 double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate( estimatedTrainingValues, originalTrainingValues, out errorState);183 double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 184 184 TrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN; 185 double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate( estimatedTestValues, originalTestValues, out errorState);185 double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 186 186 TestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN; 187 187 188 double trainingNmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate( estimatedTrainingValues, originalTrainingValues, out errorState);188 double trainingNmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 189 189 TrainingNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingNmse : double.NaN; 190 double testNmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate( estimatedTestValues, originalTestValues, out errorState);190 double testNmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 191 191 TestNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? testNmse : double.NaN; 192 192 193 double trainingDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState); 193 var startTrainingValues = originalTrainingValues; 194 // each continuation is only one element long 195 var actualContinuationsTraining = from x in originalTrainingValues.Skip(1) 196 select Enumerable.Repeat(x, 1); 197 // each forecast is only one elemnt long 198 // disregards the first estimated value (we could include this again by extending the list of original values by one step to the left 199 // this is the easier way 200 var predictedContinuationsTraining = from x in estimatedTrainingValues.Skip(1) 201 select Enumerable.Repeat(x, 1); 202 203 var startTestValues = originalTestValues; 204 var actualContinuationsTest = from x in originalTestValues.Skip(1) 205 select Enumerable.Repeat(x, 1); 206 var predictedContinuationsTest = from x in estimatedTestValues.Skip(1) 207 select Enumerable.Repeat(x, 1); 208 209 double trainingDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate(startTrainingValues, actualContinuationsTraining, predictedContinuationsTraining, out errorState); 194 210 TrainingDirectionalSymmetry = errorState == OnlineCalculatorError.None ? trainingDirectionalSymmetry : double.NaN; 195 double testDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate( estimatedTestValues, originalTestValues, out errorState);211 double testDirectionalSymmetry = OnlineDirectionalSymmetryCalculator.Calculate(startTestValues, actualContinuationsTest, predictedContinuationsTest, out errorState); 196 212 TestDirectionalSymmetry = errorState == OnlineCalculatorError.None ? testDirectionalSymmetry : double.NaN; 197 213 198 double trainingWeightedDirectionalSymmetry = OnlineWeightedDirectionalSymmetryCalculator.Calculate( estimatedTrainingValues, originalTrainingValues, out errorState);214 double trainingWeightedDirectionalSymmetry = OnlineWeightedDirectionalSymmetryCalculator.Calculate(startTrainingValues, actualContinuationsTraining, predictedContinuationsTraining, out errorState); 199 215 TrainingWeightedDirectionalSymmetry = errorState == OnlineCalculatorError.None ? trainingWeightedDirectionalSymmetry : double.NaN; 200 double testWeightedDirectionalSymmetry = OnlineWeightedDirectionalSymmetryCalculator.Calculate( estimatedTestValues, originalTestValues, out errorState);216 double testWeightedDirectionalSymmetry = OnlineWeightedDirectionalSymmetryCalculator.Calculate(startTestValues, actualContinuationsTest, predictedContinuationsTest, out errorState); 201 217 TestWeightedDirectionalSymmetry = errorState == OnlineCalculatorError.None ? testWeightedDirectionalSymmetry : double.NaN; 202 218 203 double trainingTheilsU = OnlineTheilsUStatisticCalculator.Calculate( estimatedTrainingValues, originalTrainingValues, out errorState);219 double trainingTheilsU = OnlineTheilsUStatisticCalculator.Calculate(startTrainingValues, actualContinuationsTraining, predictedContinuationsTraining, out errorState); 204 220 TrainingTheilsUStatistic = errorState == OnlineCalculatorError.None ? trainingTheilsU : double.NaN; 205 double testTheilsU = OnlineTheilsUStatisticCalculator.Calculate( estimatedTestValues, originalTestValues, out errorState);221 double testTheilsU = OnlineTheilsUStatisticCalculator.Calculate(startTestValues, actualContinuationsTest, predictedContinuationsTest, out errorState); 206 222 TestTheilsUStatistic = errorState == OnlineCalculatorError.None ? testTheilsU : double.NaN; 207 208 209 223 } 210 224 }
Note: See TracChangeset
for help on using the changeset viewer.