コード例 #1
0
ファイル: test_few_shot_fit.py プロジェクト: yangzch/adtk
def test_level_shift_ad():
    model = LevelShiftAD(window=6)
    with pytest.raises(RuntimeError):
        model.fit(s)

    model = PersistAD(window=5)
    model.fit(s)
コード例 #2
0
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),
    )