def test_level_shift_ad(): model = LevelShiftAD(window=6) with pytest.raises(RuntimeError): model.fit(s) model = PersistAD(window=5) model.fit(s)
def test_level_shift_ad(): model = LevelShiftAD(window=3) s_train = s.copy().iloc[:-10] model.fit(s_train) s_test = s.copy().iloc[-5:] s_test.iloc[-3:] = 10 pd.testing.assert_series_equal(model.predict(s_test), pd.Series([np.nan] * 5, index=s_test.index)) s_test = s.copy().iloc[-6:] s_test.iloc[-3:] = 10 pd.testing.assert_series_equal( model.predict(s_test), pd.Series([np.nan] * 3 + [1.0] + [np.nan] * 2, index=s_test.index), )