Automated hyper-parameter tuning for scikit-learn estimators using optuna.
Project description
Overview | |
---|---|
Open Source | |
CI/CD | |
Code | |
Downloads | |
Citation |
Table of Contents
About The Project
Introduction
autotuner
is an automated hyper-parameter tuning for scikit-learn
estimators using optuna
:
optuna
is an automatic hyperparameter optimization software framework, particularly designed for machine learning. It features an imperative, define-by-run style user API. Thanks to our define-by-run API, the code written with Optuna enjoys high modularity, and the user of Optuna can dynamically construct the search spaces for the hyperparameters.
- Eager search spaces: Automated search for optimal hyperparameters using Python conditionals, loops, and syntax
- State-of-the-art algorithms: Efficiently search large spaces and prune unpromising trials for faster results
- Easy parallelization: Parallelize hyperparameter searches over multiple threads or processes without modifying code
Optuna has integration features with various third-party libraries. Integrations can be found in optuna/optuna-integration
.
Autotune
is designed to automatically suggest hyperparameters that are fed into a trial object. It works with both scikit-learn
estimators and pipeline.
Why Optuna?
Optuna enables efficient hyperparameter optimization by adopting state-of-the-art algorithms for sampling hyperparameters and pruning efficiently unpromising trials.
-
Sampling Algorithms: Samplers basically continually narrow down the search space using the records of suggested parameter values and evaluated objective values, leading to an optimal search space which giving off parameters leading to better objective values.
optuna
provides the following sampling algorithms:- Grid Search
- Random Search
- Tree-structured Parzen Estimator algorithm
- CMA-ES based algorithm
- Gaussian process-based algorithm
- Algorithm to enable partial fixed parameters
- Nondominated Sorting Genetic Algorithm II
- A Quasi Monte Carlo sampling algorithm
-
Pruning Algorithms: Pruners automatically stop unpromising trials at the early stages of the training (a.k.a., automated early-stopping). Optuna provides the following pruning algorithms:
- Median pruning algorithm
- Non-pruning algorithm
- Algorithm to operate pruner with tolerance
- Algorithm to prune specified percentile of trials
- Asynchronous Successive Halving algorithm
- Hyperband algorithm
- Threshold pruning algorithm
- A pruning algorithm based on Wilcoxon signed-rank test
More information could be found in the Official Documentation.
Built With
optuna = "^3.6.1"
optuna-integration = "^3.6.0"
numpy = "^1.26.4"
scikit-learn = "^1.5.0"
pandas = "^2.2.2"
Installation
$ pip install autotuner
Getting Started
Once you have cloned the repository, you can start using autotuner
to optimize scikit-learn
hyperparameters.
>>> from sklearn.ensemble import RandomForestRegressor
>>> from autotuner import TuneEstimator
>>> model = TuneEstimator(RandomForestRegressor())
Get hyperparameters distributions:
>>> model.get_param_distributions()
# {'n_estimators': IntDistribution(high=300, log=False, low=10, step=1),
# 'max_depth': IntDistribution(high=11, log=False, low=1, step=1),
# 'min_impurity_decrease': FloatDistribution(high=0.5, log=True, low=1e-09, step=None),
# 'max_features': FloatDistribution(high=1.0, log=False, low=0.4, step=None),
# 'min_samples_split': IntDistribution(high=10, log=False, low=2, step=1),
# 'min_samples_leaf': IntDistribution(high=6, log=False, low=2, step=1),
# 'bootstrap': CategoricalDistribution(choices=(True, False)),
# 'criterion': CategoricalDistribution(choices=('squared_error', 'absolute_error'))}
Fit the estimator:
>>> model.fit(X_train, y_train)
Extract best parameters:
>>> model.best_params_
# {'n_estimators': 237,
# 'max_depth': 3,
# 'min_impurity_decrease': 2.9704981079087477e-09,
# 'max_features': 0.47361313286263895,
# 'min_samples_split': 3,
# 'min_samples_leaf': 6,
# 'bootstrap': True,
# 'criterion': 'squared_error'}
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the BSD-3 License. See LICENSE.txt
for more information.
Reference
- Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta, and Masanori Koyama. 2019.
- Optuna: A Next-generation Hyperparameter Optimization Framework. In KDD.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file autotuner-0.1.1.tar.gz
.
File metadata
- Download URL: autotuner-0.1.1.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf298a559668a43df4cf1b8cc832f554f2fc30dc5e742bfbc701fa11941d6abd |
|
MD5 | 35e77ec1e55e79755b876334d1485323 |
|
BLAKE2b-256 | 546d0330456a007bf69ebfd3e389feacf9a417f12e41f2baeb249c719dcf7c08 |
File details
Details for the file autotuner-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: autotuner-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3460bdd9b0ad34808ba8c558bbe55a9e8bad5f12492e96993496ad7347987e0b |
|
MD5 | 7ef3df35b890ce11f5aa336793cfb97b |
|
BLAKE2b-256 | 6e4ad61435ed86da90fdac11a2921e91eed9b0781d4b211cad9f32d50661a768 |