Ejemplo n.º 1
0
 def test_predict_target_to_feature_dict(self, data, X_y, estimator):
     X, y = X_y
     X_train, y_train, X_test, y_test = FeatureSplitter().transform(X, y)
     target_to_feature_dict = data.draw(
         str_target_to_feature_dicts(targets=y.columns, features=X.columns)
     )
     multi_feature_gar = MultiFeatureGAR(estimator)
     multi_feature_gar.fit(X_train, y_train, target_to_features_dict=target_to_feature_dict)
     multi_feature_gar.predict(X_test)
Ejemplo n.º 2
0
 def test_error_predict_target_to_feature_dict_wrong_X_shape(
         self, data, X_y, estimator):
     X, y = X_y
     X_train, y_train, X_test, y_test = FeatureSplitter().transform(X, y)
     target_to_feature_dict = data.draw(
         str_target_to_feature_dicts(targets=y.columns, features=X.columns))
     multi_feature_gar = MultiFeatureGAR(
         estimator, target_to_features_dict=target_to_feature_dict)
     multi_feature_gar.fit(X_train, y_train)
     X_test = X_test.iloc[:, :2]
     with pytest.raises(ValueError):
         multi_feature_gar.predict(X_test)
Ejemplo n.º 3
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),
        )
Ejemplo n.º 4
0
 def test_error_predict_with_no_fit(self, estimator, X):
     regressor = MultiFeatureGAR(estimator)
     with pytest.raises(NotFittedError):
         regressor.predict(X)