Esempio n. 1
0
    def test_predict_with_no_fit(self, time_series):
        base_model = LinearRegression()

        gar_no_feedforward = GAR(estimator=base_model)

        with pytest.raises(NotFittedError):
            gar_no_feedforward.predict(time_series)
Esempio n. 2
0
    def test_fit_as_multi_output_regressor_if_target_to_feature_none(
        self, estimator, X_y
    ):
        X, y = X_y
        X_train, y_train, X_test, y_test = FeatureSplitter().transform(X, y)
        multi_feature_gar = MultiFeatureGAR(estimator)
        multi_feature_gar.fit(X_train, y_train)

        gar = GAR(estimator)
        gar.fit(X_train, y_train)

        pd.testing.assert_frame_equal(
            multi_feature_gar.predict(X_test), gar.predict(X_test),
        )
Esempio n. 3
0
 def __init__(self, p: int, horizon: int):
     features = [
         tuple((f"s{i}", Shift(i),
                make_column_selector(dtype_include=np.number)))
         for i in range(1, p + 1)
     ]
     model = GAR(LinearRegression())
     super().__init__(features=features, horizon=horizon, model=model)
Esempio n. 4
0
    def test_correct_fit_date(self, X_y):
        base_model = LinearRegression()
        feature_splitter = FeatureSplitter()
        x, y = X_y[0], X_y[1]
        x_train, y_train, x_test, y_test = feature_splitter.transform(x, y)

        gar_no_feedforward = GAR(estimator=base_model)

        gar_no_feedforward.fit(x_train, y_train)

        predictions = gar_no_feedforward.predict(x_test)

        assert len(predictions) == len(x_test)
        np.testing.assert_array_equal(predictions.index, x_test.index)

        gar_with_feedforward = GARFF(estimator=base_model)

        gar_with_feedforward.fit(x_train, y_train)

        predictions = gar_with_feedforward.predict(x_test)

        assert len(predictions) == len(x_test)
        np.testing.assert_array_equal(predictions.index, x_test.index)
Esempio n. 5
0
 def __init__(
     self,
     p: int,
     horizon: Union[int, List[int]],
     explainer_type: Optional[str] = None,
 ):
     self.p = p
     self.explainer_type = explainer_type
     features = [
         tuple((f"s{i}", Shift(i), make_column_selector(dtype_include=np.number)))
         for i in range(p)
     ]
     model = GAR(LinearRegression(), explainer_type=explainer_type)
     super().__init__(features=features, horizon=horizon, model=model)
Esempio n. 6
0
def model2():
    lr = Ridge(alpha=0.1)
    return GAR(lr)
Esempio n. 7
0
def model1():
    lr = LinearRegression()
    return GAR(lr)