Changeset 7183 for branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis
- Timestamp:
- 12/13/11 13:52:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs
r7160 r7183 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Concurrent; 23 24 using System.Collections.Generic; … … 195 196 private void AfterDeserialization() { 196 197 if (horizon == 0) horizon = 1; 198 bool anyNewResult = false; 199 if (!ContainsKey(TrainingTheilsUStatisticLastResultName)) { 200 Add(new Result(TrainingTheilsUStatisticLastResultName, "The average Theil's U statistic (reference: previous value) of the forecasts of the model on the training partition", new DoubleArray())); 201 anyNewResult = true; 202 } 203 if (!ContainsKey(TestTheilsUStatisticLastResultName)) { 204 Add(new Result(TestTheilsUStatisticLastResultName, "The average Theil's U statistic (reference: previous value) of the forecasts of the model on the test partition", new DoubleArray())); 205 anyNewResult = true; 206 } 207 if (!ContainsKey(TrainingTheilsUStatisticMeanResultName)) { 208 Add(new Result(TrainingTheilsUStatisticMeanResultName, "The average Theil's U statistic (reference: mean value) of the forecasts of the model on the training partition", new DoubleArray())); 209 anyNewResult = true; 210 } 211 if (!ContainsKey(TestTheilsUStatisticMeanResultName)) { 212 Add(new Result(TestTheilsUStatisticMeanResultName, "The average Theil's U statistic (reference: mean value) of the forecasts of the model on the test partition", new DoubleArray())); 213 anyNewResult = true; 214 } 215 if (!ContainsKey(TrainingTheilsUStatisticMAResultName)) { 216 Add(new Result(TrainingTheilsUStatisticMAResultName, "The average Theil's U statistic (reference: moving average) of the forecasts of the model on the training partition", new DoubleArray())); 217 anyNewResult = true; 218 } 219 if (!ContainsKey(TestTheilsUStatisticMAResultName)) { 220 Add(new Result(TestTheilsUStatisticMAResultName, "The average Theil's U statistic (reference: moving average) of the forecasts of the model on the test partition", new DoubleArray())); 221 anyNewResult = true; 222 } 223 if (anyNewResult) 224 RecalculateResults(); 197 225 } 198 226 … … 240 268 //double[] trainingTheilsU = new double[targetVariables.Length]; 241 269 //double[] testTheilsU = new double[targetVariables.Length]; 270 271 var trainingMseCalculators = new OnlineMeanSquaredErrorCalculator[targetVariables.Length]; 272 var testMseCalculators = new OnlineMeanSquaredErrorCalculator[targetVariables.Length]; 273 var trainingMaeCalculators = new OnlineMeanAbsoluteErrorCalculator[targetVariables.Length]; 274 var testMaeCalculators = new OnlineMeanAbsoluteErrorCalculator[targetVariables.Length]; 275 var trainingRSquaredCalculators = new OnlinePearsonsRSquaredCalculator[targetVariables.Length]; 276 var testRSquaredCalculators = new OnlinePearsonsRSquaredCalculator[targetVariables.Length]; 277 var trainingRelErrorCalculators = new OnlineMeanAbsolutePercentageErrorCalculator[targetVariables.Length]; 278 var testRelErrorCalculators = new OnlineMeanAbsolutePercentageErrorCalculator[targetVariables.Length]; 279 var trainingNmseCalculators = new OnlineNormalizedMeanSquaredErrorCalculator[targetVariables.Length]; 280 var testNmseCalculators = new OnlineNormalizedMeanSquaredErrorCalculator[targetVariables.Length]; 242 281 243 282 var trainingDsCalculators = new OnlineDirectionalSymmetryCalculator[targetVariables.Length]; … … 252 291 var testTheilsUMovingAverageCalculators = new OnlineTheilsUStatisticCalculator[targetVariables.Length]; 253 292 for (int i = 0; i < targetVariables.Length; i++) { 293 trainingMseCalculators[i] = new OnlineMeanSquaredErrorCalculator(); 294 testMseCalculators[i] = new OnlineMeanSquaredErrorCalculator(); 295 trainingMaeCalculators[i] = new OnlineMeanAbsoluteErrorCalculator(); 296 testMaeCalculators[i] = new OnlineMeanAbsoluteErrorCalculator(); 297 trainingRSquaredCalculators[i] = new OnlinePearsonsRSquaredCalculator(); 298 testRSquaredCalculators[i] = new OnlinePearsonsRSquaredCalculator(); 299 trainingRelErrorCalculators[i] = new OnlineMeanAbsolutePercentageErrorCalculator(); 300 testRelErrorCalculators[i] = new OnlineMeanAbsolutePercentageErrorCalculator(); 301 trainingNmseCalculators[i] = new OnlineNormalizedMeanSquaredErrorCalculator(); 302 testNmseCalculators[i] = new OnlineNormalizedMeanSquaredErrorCalculator(); 303 254 304 trainingDsCalculators[i] = new OnlineDirectionalSymmetryCalculator(); 255 305 testDsCalculators[i] = new OnlineDirectionalSymmetryCalculator(); … … 286 336 trainingTheilsUMeanCalculators[t].Add(startValue, actualContinuation.Select(x => mean), actualContinuation, prognosedContinuation); 287 337 trainingTheilsUMovingAverageCalculators[t].Add(startValue, movingAverageContinuation, actualContinuation, prognosedContinuation); 338 339 var actualContinuationEnumerator = actualContinuation.GetEnumerator(); 340 var prognosedContinuationEnumerator = prognosedContinuation.GetEnumerator(); 341 while (actualContinuationEnumerator.MoveNext() & prognosedContinuationEnumerator.MoveNext()) { 342 trainingMseCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 343 trainingMaeCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 344 trainingRelErrorCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 345 trainingRSquaredCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 346 trainingNmseCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 347 } 348 if (actualContinuationEnumerator.MoveNext() | prognosedContinuationEnumerator.MoveNext()) 349 throw new ArgumentException( 350 "Different number of elements in Actual continuation and prognosed continuation."); 288 351 } 289 352 } … … 312 375 testTheilsUMeanCalculators[t].Add(startValue, actualContinuation.Select(x => mean), actualContinuation, prognosedContinuation); 313 376 testTheilsUMovingAverageCalculators[t].Add(startValue, movingAverageContinuation, actualContinuation, prognosedContinuation); 377 378 var actualContinuationEnumerator = actualContinuation.GetEnumerator(); 379 var prognosedContinuationEnumerator = prognosedContinuation.GetEnumerator(); 380 while (actualContinuationEnumerator.MoveNext() & prognosedContinuationEnumerator.MoveNext()) { 381 testMseCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 382 testMaeCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 383 testRelErrorCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 384 testRSquaredCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 385 testNmseCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current); 386 } 387 if (actualContinuationEnumerator.MoveNext() | prognosedContinuationEnumerator.MoveNext()) 388 throw new ArgumentException( 389 "Different number of elements in Actual continuation and prognosed continuation."); 314 390 } 315 391 } 316 392 } 317 393 394 395 TrainingMeanSquaredError = trainingMseCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity) 396 .ToArray(); 397 TestMeanSquaredError = testMseCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity) 398 .ToArray(); 399 TrainingMeanAbsoluteError = trainingMaeCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity) 400 .ToArray(); 401 TestMeanAbsoluteError = testMaeCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity) 402 .ToArray(); 403 TrainingRelativeError = trainingRelErrorCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity) 404 .ToArray(); 405 TestRelativeError = testRelErrorCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity) 406 .ToArray(); 407 TrainingRSquared = trainingRSquaredCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : 0.0) 408 .ToArray(); 409 TestRSquared = testRSquaredCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : 0.0) 410 .ToArray(); 411 TrainingNormalizedMeanSquaredError = trainingNmseCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity) 412 .ToArray(); 413 TestNormalizedMeanSquaredError = testNmseCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity) 414 .ToArray(); 415 318 416 TrainingDirectionalSymmetry = trainingDsCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : 0.0) 319 417 .ToArray();
Note: See TracChangeset
for help on using the changeset viewer.