Google Colab and AutoML: Auto-sklearn Setup

Logos of Google Drive + Colab + Scikit-learn + Auto-sklearn
!sudo apt-get install build-essential swig
!pip install auto-sklearn==0.11.1
Airbnb dataset description
Training dataset before transformations
Training dataset after transformations
import autosklearn.regression
automl = autosklearn.regression.AutoSklearnRegressor(
time_left_for_this_task=120,
per_run_time_limit=30,
n_jobs=1
)
automl.fit(
X_train_transformed,
y_train
)
import sklearn.metrics
predictions = automl.predict(X_test_transformed)
sklearn.metrics.r2_score(y_test, predictions)
# output: 0.1862
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import GridSearchCV
model = RandomForestRegressor(max_depth=3, random_state=0)
parameters = {
"max_depth": (2, 3, 5)
}
grid = GridSearchCV(model, parameters, cv=5, scoring="r2")
grid.fit(X_train_transformed, y_train.values.ravel())
predictions = grid.predict(X_test_transformed)
sklearn.metrics.r2_score(y_test, predictions)
# output: 0.0982

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store