@Test public void testExcessTrainingFails() { expectedEx.expect(IllegalArgumentException.class); expectedEx.expectMessage(String.format( "Training invoked %d times which is greater than the training window of frequency * 2 (%d * 2 = %d) observations.", (HoltWintersAustouristsTestHelper.AUSTOURISTS_FREQUENCY * 2) + 1, HoltWintersAustouristsTestHelper.AUSTOURISTS_FREQUENCY, HoltWintersAustouristsTestHelper.AUSTOURISTS_FREQUENCY * 2)); HoltWintersPointForecasterParams params = HoltWintersAustouristsTestHelper.buildAustouristsParams(HoltWintersSeasonalityType.MULTIPLICATIVE) .setInitTrainingMethod(HoltWintersTrainingMethod.SIMPLE); HoltWintersOnlineComponents components = new HoltWintersOnlineComponents(params); HoltWintersSimpleTrainingModel subject = new HoltWintersSimpleTrainingModel(params); for (int i = 0; i < 9; i++) { subject.observeAndTrain(i, params, components); } }
public void observeAndTrain(double y, HoltWintersPointForecasterParams params, HoltWintersOnlineComponents components) { checkNulls(params, components); checkTrainingMethod(params); checkStillInInitialTraining(params); int frequency = params.getFrequency(); if (isBetween(n, 0, frequency - 1)) { firstCycle[n] = y; } else { secondCycle[n - frequency] = y; } if (n == params.calculateInitTrainingPeriod() - 1) { setLevel(components); setSeasonals(y, params, components); setBase(params, components); updateComponentsAndForecast(params, components); } n++; }
HoltWintersSimpleTrainingModel { public void observeAndTrain(double y, HoltWintersPointForecasterParams params, HoltWintersOnlineComponents components) { checkNulls(params, components); checkTrainingMethod(params); checkStillInInitialTraining(params); int frequency = params.getFrequency(); if (isBetween(n, 0, frequency - 1)) { firstCycle[n] = y; } else { secondCycle[n - frequency] = y; } if (n == params.calculateInitTrainingPeriod() - 1) { setLevel(components); setSeasonals(y, params, components); setBase(params, components); updateComponentsAndForecast(params, components); } n++; } }
HoltWintersSimpleTrainingModel { public void observeAndTrain(double y, HoltWintersPointForecasterParams params, HoltWintersOnlineComponents components) { checkNulls(params, components); checkTrainingMethod(params); checkStillInInitialTraining(params); int frequency = params.getFrequency(); if (isBetween(n, 0, frequency - 1)) { firstCycle[n] = y; } else { secondCycle[n - frequency] = y; } if (n == params.calculateInitTrainingPeriod() - 1) { setLevel(components); setSeasonals(y, params, components); setBase(params, components); updateComponentsAndForecast(params, components); } n++; } HoltWintersSimpleTrainingModel(HoltWintersPointForecasterParams params); }
HoltWintersSimpleTrainingModel { public void observeAndTrain(double y, HoltWintersPointForecasterParams params, HoltWintersOnlineComponents components) { checkNulls(params, components); checkTrainingMethod(params); checkStillInInitialTraining(params); int frequency = params.getFrequency(); if (isBetween(n, 0, frequency - 1)) { firstCycle[n] = y; } else { secondCycle[n - frequency] = y; } if (n == params.calculateInitTrainingPeriod() - 1) { setLevel(components); setSeasonals(y, params, components); setBase(params, components); updateComponentsAndForecast(params, components); } n++; } HoltWintersSimpleTrainingModel(HoltWintersPointForecasterParams params); void observeAndTrain(double y, HoltWintersPointForecasterParams params, HoltWintersOnlineComponents components); boolean isTrainingComplete(HoltWintersPointForecasterParams params); }
HoltWintersSimpleTrainingModel { public void observeAndTrain(double y, HoltWintersPointForecasterParams params, HoltWintersOnlineComponents components) { checkNulls(params, components); checkTrainingMethod(params); checkStillInInitialTraining(params); int frequency = params.getFrequency(); if (isBetween(n, 0, frequency - 1)) { firstCycle[n] = y; } else { secondCycle[n - frequency] = y; } if (n == params.calculateInitTrainingPeriod() - 1) { setLevel(components); setSeasonals(y, params, components); setBase(params, components); updateComponentsAndForecast(params, components); } n++; } HoltWintersSimpleTrainingModel(HoltWintersPointForecasterParams params); void observeAndTrain(double y, HoltWintersPointForecasterParams params, HoltWintersOnlineComponents components); boolean isTrainingComplete(HoltWintersPointForecasterParams params);  }