Skip to content

Instantly share code, notes, and snippets.

@vivek081166
Created April 23, 2019 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivek081166/c7525b28aceaf1f77f0995eb0b01c983 to your computer and use it in GitHub Desktop.
Save vivek081166/c7525b28aceaf1f77f0995eb0b01c983 to your computer and use it in GitHub Desktop.
import sklearn.model_selection
import sklearn.datasets
import sklearn.metrics
import autosklearn.regression
def main():
X, y = sklearn.datasets.load_boston(return_X_y=True)
feature_types = (['numerical'] * 3) + ['categorical'] + (['numerical'] * 9)
X_train, X_test, y_train, y_test = \
sklearn.model_selection.train_test_split(X, y, random_state=1)
automl = autosklearn.regression.AutoSklearnRegressor(
time_left_for_this_task=120,
per_run_time_limit=30,
tmp_folder='/tmp/autosklearn_regression_example_tmp',
output_folder='/tmp/autosklearn_regression_example_out',
)
automl.fit(X_train, y_train, dataset_name='boston',
feat_type=feature_types)
print(automl.show_models())
predictions = automl.predict(X_test)
print("R2 score:", sklearn.metrics.r2_score(y_test, predictions))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment