{"id":15501679,"url":"https://github.com/yard1/hpbandster-sklearn","last_synced_at":"2025-04-22T21:45:36.937Z","repository":{"id":62569487,"uuid":"304442389","full_name":"Yard1/hpbandster-sklearn","owner":"Yard1","description":"A scikit-learn wrapper for HpBandSter hyper parameter search.","archived":false,"fork":false,"pushed_at":"2022-10-15T12:38:58.000Z","size":128,"stargazers_count":22,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T14:40:53.403Z","etag":null,"topics":["automated-machine-learning","automl","bayesian-optimization","hyperparameter-optimization","hyperparameter-tuning","machine-learning","python","scikit-learn","sklearn"],"latest_commit_sha":null,"homepage":"https://hpbandster-sklearn.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yard1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-15T20:36:53.000Z","updated_at":"2025-02-21T15:53:07.000Z","dependencies_parsed_at":"2022-11-03T17:15:24.926Z","dependency_job_id":null,"html_url":"https://github.com/Yard1/hpbandster-sklearn","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yard1%2Fhpbandster-sklearn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yard1%2Fhpbandster-sklearn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yard1%2Fhpbandster-sklearn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yard1%2Fhpbandster-sklearn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yard1","download_url":"https://codeload.github.com/Yard1/hpbandster-sklearn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250330565,"owners_count":21412998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automated-machine-learning","automl","bayesian-optimization","hyperparameter-optimization","hyperparameter-tuning","machine-learning","python","scikit-learn","sklearn"],"created_at":"2024-10-02T09:05:18.800Z","updated_at":"2025-04-22T21:45:36.904Z","avatar_url":"https://github.com/Yard1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hpbandster-sklearn\n\n`hpbandster-sklearn` is a Python library providing a [`scikit-learn`](http://scikit-learn.org/) wrapper - `HpBandSterSearchCV` - for [`HpBandSter`](https://github.com/automl/HpBandSter), a hyper parameter tuning library.\n\n## Motivation\n\n`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.\n\n`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.\n\n`HpBandSterSearchCV` API has been based on `scikit-learn`'s [`HalvingRandomSearchCV`](https://scikit-learn.org/dev/modules/generated/sklearn.model_selection.HalvingRandomSearchCV.html), implementing nearly all of the parameters it does.\n\n## Installation\n\n```\npip install hpbandster-sklearn\n```\n\n## Usage\n\nUse it like any other `scikit-learn` hyper parameter searcher:\n\n```python\nimport numpy as np\nfrom sklearn.datasets import load_iris\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.utils.validation import check_is_fitted\nfrom hpbandster_sklearn import HpBandSterSearchCV\n\nX, y = load_iris(return_X_y=True)\nclf = RandomForestClassifier(random_state=0)\nnp.random.seed(0)\n\nparam_distributions = {\"max_depth\": [2, 3, 4], \"min_samples_split\": list(range(2, 12))}\n\nsearch = HpBandSterSearchCV(clf, param_distributions,random_state=0, n_jobs=1, n_iter=10, verbose=1).fit(X, y)\nsearch.best_params_\n```\n\nYou can also use `ConfigSpace.ConfigurationSpace` objects instead of dicts (in fact, it is recommended)!\n\n```python\nimport numpy as np\nfrom sklearn.datasets import load_iris\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.utils.validation import check_is_fitted\nfrom hpbandster_sklearn import HpBandSterSearchCV\nimport ConfigSpace as CS\nimport ConfigSpace.hyperparameters as CSH\n\nX, y = load_iris(return_X_y=True)\nclf = RandomForestClassifier(random_state=0)\nnp.random.seed(0)\n\nparam_distributions = CS.ConfigurationSpace(seed=42)\nparam_distributions.add_hyperparameter(CSH.UniformIntegerHyperparameter(\"min_samples_split\", 2, 11))\nparam_distributions.add_hyperparameter(CSH.UniformIntegerHyperparameter(\"max_depth\", 2, 4))\n\nsearch = HpBandSterSearchCV(clf, param_distributions,random_state=0, n_jobs=1, n_iter=10, verbose=1).fit(X, y)\nsearch.best_params_\n```\n\nPlease refer to the [documentation of this library](https://hpbandster-sklearn.readthedocs.io/en/latest/), as well as to the documentation of [`HpBandSter`](https://automl.github.io/HpBandSter/build/html/index.html) and [`ConfigSpace`](https://automl.github.io/ConfigSpace/master/index.html) for more information.\n\nPipelines and `TransformedTargetRegressor` are also supported. Make sure to prefix the hyper parameter and resource names accordingly should you use either (or both) - for example, `final_estimator__n_estimators`. `n_samples` is not to be prefixed.\n\n## Early stopping\n\nAs almost every search algorithm in `HpBandSter` leverages early stopping (mostly through Successive Halving), the user can configure the resource and budget to be used through the arguments of `HpBandSterSearchCV` object.\n\n```python\nsearch = HpBandSterSearchCV(\n    clf,\n    param_distributions,\n    resource_name='n_samples', # can be either 'n_samples' or a string corresponding to an estimator attribute, eg. 'n_estimators' for an ensemble\n    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\n    min_budget=0.2,\n    max_budget=1,\n)\n\nsearch = HpBandSterSearchCV(\n    clf,\n    param_distributions,\n    resource_name='n_estimators', # can be either 'n_samples' or a string corresponding to an estimator attribute, eg. 'n_estimators' for an ensemble\n    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\n    min_budget=20,\n    max_budget=200,\n)\n```\n\nBy default, the object will try to automatically determine the best resource, by checking the following in order:\n\n- `'n_estimators'`, if the model has that attribute and the `warm_start` attribute\n- `'max_iter'`, if the model has that attribute and the `warm_start` attribute\n- `'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.\n\nFurthermore, special support has been added for `LightGBM`, `XGBoost` and `CatBoost` `scikit-learn` estimators.\n\n## Documentation\n\nhttps://hpbandster-sklearn.readthedocs.io/en/latest/\n\n## References\n\n- `HpBandSter` - https://github.com/automl/HpBandSter\n- `ConfigSpace` - https://github.com/automl/ConfigSpace\n- `scikit-learn` - http://scikit-learn.org/\n\n## Author\n\nAntoni Baum (Yard1)\n\n## License\n\n[MIT](https://github.com/Yard1/hpbandster-sklearn/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyard1%2Fhpbandster-sklearn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyard1%2Fhpbandster-sklearn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyard1%2Fhpbandster-sklearn/lists"}