Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 2.0.2 instead.
Reason given by maintainers: Broken install. Use 1.0.1.

hpbandster-sklearn

hpbandster-sklearn is a Python library providing a scikit-learn wrapper - HpBandSterSearchCV - for HpBandSter, a hyper parameter tuning library.

Motivation

HpBandSter implements several cutting-edge hyper parameter algorithms, including HyperBand and BOHB. They often outperform standard Random Search, finding best parameter combinations in less time.

HpBandSter is powerful and configurable, but its usage is often unintuitive for beginners and necessitating a large amount of boilerplate code. In order to solve that issue, HpBandSterSearchCV was created as a drop-in replacement for scikit-learn hyper parameter searchers, following its well-known and popular API, making it possible to tune scikit-learn API estimators with minimal setup.

HpBandSterSearchCV API has been based on scikit-learn's HalvingRandomSearchCV, implementing nearly all of the parameters it does.

Installation

pip install hpbandster-sklearn

Usage

Use it like any other scikit-learn hyper parameter searcher:

import numpy as np
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.utils.validation import check_is_fitted
from hpbandster_sklearn import HpBandSterSearchCV

X, y = load_iris(return_X_y=True)
clf = RandomForestClassifier(random_state=0)
np.random.seed(0)

param_distributions = {"max_depth": [2, 3, 4], "min_samples_split": list(range(2, 12))}

search = HpBandSterSearchCV(clf, param_distributions,random_state=0, n_jobs=1, n_iter=10, verbose=1).fit(X, y)
search.best_parameters_

You can also use ConfigSpace.ConfigurationSpace objects instead of dicts (in fact, it is recommended)!

import numpy as np
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.utils.validation import check_is_fitted
from hpbandster_sklearn import HpBandSterSearchCV
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH

X, y = load_iris(return_X_y=True)
clf = RandomForestClassifier(random_state=0)
np.random.seed(0)

param_distributions = CS.ConfigurationSpace(seed=42)
param_distributions.add_hyperparameter(CSH.UniformIntegerHyperparameter("min_samples_split", 2, 11))
param_distributions.add_hyperparameter(CSH.UniformIntegerHyperparameter("max_depth", 2, 4))

search = HpBandSterSearchCV(clf, param_distributions,random_state=0, n_jobs=1, n_iter=10, verbose=1).fit(X, y)
search.best_parameters_

Please refer to the documentation of this library, as well as to the documentation of HpBandSter and ConfigSpace for more information.

Early stopping

As almost every search algorithm in HpBandSter leverages early stopping (tmostly through Successive Halving), the user can configure the resource and budget to be used through the arguments of HpBandSterSearchCV object.

search = HpBandSterSearchCV(
    clf,
    param_distributions,
    resource_name='n_samples', # can be either 'n_samples' or a string corresponding to an estimator attribute, eg. 'n_estimators' for an ensemble
    resource_type=float, # if specified, the resource value will be cast to that type before being passed to the estimator, otherwise it will be derived automatically
    min_budget=0.2,
    max_budget=1,
)

search = HpBandSterSearchCV(
    clf,
    param_distributions,
    resource_name='n_estimators', # can be either 'n_samples' or a string corresponding to an estimator attribute, eg. 'n_estimators' for an ensemble
    resource_type=int, # if specified, the resource value will be cast to that type before being passed to the estimator, otherwise it will be derived automatically
    min_budget=20,
    max_budget=200,
)

By default, the object will try to automatically determine the best resource, by checking the following in order:

  • 'n_estimators', if the model has that attribute and the warm_start attribute
  • 'max_iter', if the model has that attribute and the warm_start attribute
  • 'n_samples' - if the model doesn't support warm_start, the dataset samples will be used as the resource instead, meaing the model will be iteratively fitted on a bigger and bigger portion of the dataset.

Furthermore, special support has been added for LightGBM, XGBoost and CatBoost scikit-learn estimators.

Documentation

https://hpbandster-sklearn.readthedocs.io/en/latest/

References

Author

Antoni Baum (Yard1)

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hpbandster-sklearn-1.0.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hpbandster_sklearn-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file hpbandster-sklearn-1.0.0.tar.gz.

File metadata

  • Download URL: hpbandster-sklearn-1.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for hpbandster-sklearn-1.0.0.tar.gz
Algorithm Hash digest
SHA256 af72ee4bbc4ae1bbadbe0415d7ddfd6e08648dde71f481ca802b4a65be9c4efc
MD5 d6fe94e78bb45796f76daaa6cad848e9
BLAKE2b-256 8372af6fd3e24de88dceb0caa060e89798dff66f3afd83cc8dc58850d1979fc8

See more details on using hashes here.

File details

Details for the file hpbandster_sklearn-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hpbandster_sklearn-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for hpbandster_sklearn-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cf51ea29898a7751fe41de6ccf129401d7211a061ca54d2e714aeefee9e507b
MD5 6935f402b4f3e8163c929c27a848972f
BLAKE2b-256 b04078d06c82dd54d8f4c46cf4562298551e48093a94607dcef842b8a4325e2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page