def test_fit_cache_stores_all_training_params( self, time_series, time_series_forecasting_model1_cache): time_series_forecasting_model1_cache.fit(time_series) assert hasattr(time_series_forecasting_model1_cache, "model_") assert hasattr(time_series_forecasting_model1_cache, "X_test_") assert hasattr(time_series_forecasting_model1_cache, "X_train_") assert hasattr(time_series_forecasting_model1_cache, "y_train_")
def test_error_fit_twice_set_features_only_models( self, time_series, time_series_forecasting_model1_cache, features2): time_series_forecasting_model1_cache.fit(time_series) time_series_forecasting_model1_cache.set_params(features=features2) with pytest.raises(sklearn.exceptions.NotFittedError): time_series_forecasting_model1_cache.fit(time_series, only_model=True)
def test_score_y_test(self, time_series, time_series_forecasting_model1_cache): time_series_forecasting_model1_cache.fit(time_series) len_test = time_series_forecasting_model1_cache.horizon + 2 X_test = time_series.iloc[-len_test:] score = time_series_forecasting_model1_cache.score(X=X_test) assert score.shape == (1, 2) assert all(map(lambda x: x >= 0.0, score.iloc[0]))
def test_fit_twice_set_model_only_models( self, time_series, time_series_forecasting_model1_cache, model2): time_series_forecasting_model1_cache.fit(time_series) time_series_forecasting_model1_cache.set_params(model=model2) time_series_forecasting_model1_cache.fit(time_series, only_model=True)
def test_fit_twice_only_models(self, time_series, time_series_forecasting_model1_cache): time_series_forecasting_model1_cache.fit(time_series).fit( time_series, only_model=True)
def test_error_fit_once_only_models(self, time_series, time_series_forecasting_model1_cache): with pytest.raises(sklearn.exceptions.NotFittedError): time_series_forecasting_model1_cache.fit(time_series, only_model=True)
def test_score_default(self, time_series, time_series_forecasting_model1_cache): time_series_forecasting_model1_cache.fit(time_series) score = time_series_forecasting_model1_cache.score() assert score.shape == (1, 2) assert all(map(lambda x: x >= 0.0, score.iloc[0]))
def test_score_custom(self, time_series, time_series_forecasting_model1_cache, metrics): time_series_forecasting_model1_cache.fit(time_series) score = time_series_forecasting_model1_cache.score(metrics=metrics) assert score.shape == (2, 2) assert all(map(lambda x: x >= 0.0, score.iloc[0]))