def test_estimator_fh(freqstr): """Test model fitting with anchored frequency.""" train = pd.Series( np.random.uniform(low=2000, high=7000, size=(104, )), index=pd.date_range("2019-01-02", freq=freqstr, periods=104), ) forecaster = AutoETS(auto=True, sp=52, n_jobs=-1, restrict=True) forecaster.fit(train) pred = forecaster.predict(np.arange(1, 27)) expected_fh = ForecastingHorizon(np.arange(1, 27)).to_absolute( train.index[-1]) assert_array_equal(pred.index.to_numpy(), expected_fh.to_numpy())
def test_auto_ets(): """Fix bug in 1435. https://github.com/alan-turing-institute/sktime/issues/1435#issue-1000175469 """ freq = "30T" _y = np.arange(50) + np.random.rand(50) + np.sin(np.arange(50) / 4) * 10 t = pd.date_range("2021-09-19", periods=50, freq=freq) y = pd.Series(_y, index=t) y.index = y.index.to_period(freq=freq) forecaster = AutoETS(sp=12, auto=True, n_jobs=-1) forecaster.fit(y) y_pred = forecaster.predict(fh=[1, 2, 3]) pd.testing.assert_index_equal( y_pred.index, pd.date_range("2021-09-19", periods=53, freq=freq)[-3:].to_period(freq=freq), )