Home

Awesome

Hyperband

Build Status CircleCI Coverage Status

A scikit-learn compatible implementation of hyperband.

Installation

Clone the git repository

git clone https://github.com/thuijskens/scikit-hyperband.git

and cd into the project directory and and install the package using setuptools as follows

python setup.py install

Example usage

scikit-hyperband implements a class HyperbandSearchCV that works exactly as GridSearchCV and RandomizedSearchCV from scikit-learn do, except that it runs the hyperband algorithm under the hood.

Similarly to the existing model selection routines, HyperbandSearchCV works for (multi-label) classification and regression, and supports multi-metric scoring in the same way as scikit-learn supports it.

HyperbandSearchCV implements the following extra parameters, specific to the hyperband algorithm:

See the documentation for the full parameter list.

from hyperband import HyperbandSearchCV

from scipy.stats import randint as sp_randint
from sklearn.datasets import load_digits
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import LabelBinarizer

model = RandomForestClassifier()
param_dist = {
    'max_depth': [3, None],
    'max_features': sp_randint(1, 11),
    'min_samples_split': sp_randint(2, 11),
    'min_samples_leaf': sp_randint(1, 11),
    'bootstrap': [True, False],
    'criterion': ['gini', 'entropy']
}

digits = load_digits()
X, y = digits.data, digits.target
y = LabelBinarizer().fit_transform(y)

search = HyperbandSearchCV(model, param_dist, 
                           resource_param='n_estimators',
                           scoring='roc_auc')
search.fit(X, y)
print(search.best_params_)

References