mirror of
https://github.com/microsoft/autogen.git
synced 2026-02-04 02:24:56 -05:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user