multioutput regression (#292)

* make AutoML inherit sklearn.base.BaseEstimator such that it can be wrapped in sklearn.multioutput.MultiOutputRegressor for multi-output regression.

* moved and simplified preprocessing code in AutoML.predictI() to _preprocess()
This commit is contained in:
Chi Wang
2021-11-22 06:59:42 -08:00
committed by GitHub
parent 00da79a90b
commit d937b03e42
3 changed files with 58 additions and 36 deletions

View File

@@ -195,5 +195,26 @@ class TestRegression(unittest.TestCase):
print(automl_experiment.best_config_train_time)
def test_multioutput():
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
from sklearn.multioutput import MultiOutputRegressor
# create regression data
X, y = make_regression(n_targets=3)
# split into train and test data
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.30, random_state=42
)
# train the model
model = MultiOutputRegressor(AutoML(task="regression", time_budget=1))
model.fit(X_train, y_train)
# predict
print(model.predict(X_test))
if __name__ == "__main__":
unittest.main()