optuna

A hyperparameter optimization framework

https://github.com/optuna/optuna

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    13 of 302 committers (4.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.6%) to scientific vocabulary

Keywords

distributed hyperparameter-optimization machine-learning parallel python

Keywords from Contributors

tensors rocm nvrtc nvtx nccl cutensor cusparselt cusparse cusolver curand
Last synced: 4 months ago · JSON representation ·

Repository

A hyperparameter optimization framework

Basic Info
  • Host: GitHub
  • Owner: optuna
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage: https://optuna.org
  • Size: 21 MB
Statistics
  • Stars: 12,575
  • Watchers: 122
  • Forks: 1,155
  • Open Issues: 56
  • Releases: 75
Topics
distributed hyperparameter-optimization machine-learning parallel python
Created almost 8 years ago · Last pushed 4 months ago
Metadata Files
Readme Contributing Funding License Code of conduct Citation

README.md

Optuna: A hyperparameter optimization framework

Python pypi conda GitHub license Read the Docs Codecov

:link: Website | :pagewithcurl: Docs | :gear: Install Guide | :pencil: Tutorial | :bulb: Examples | Twitter | LinkedIn | Medium

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.

:loudspeaker: News

Help us create the next version of Optuna!

Optuna 5.0 Roadmap published for review. Please take a look at the planned improvements to Optuna, and share your feedback in the github issues. PR contributions also welcome!

Please take a few minutes to fill in this survey, and let us know how you use Optuna now and what improvements you'd like.🤔 All questions are optional. 🙇‍♂️

:fire: Key Features

Optuna has modern functionalities as follows:

Basic Concepts

We use the terms study and trial as follows:

  • Study: optimization based on an objective function
  • Trial: a single execution of the objective function

Please refer to the sample code below. The goal of a study is to find out the optimal set of hyperparameter values (e.g., regressor and svr_c) through multiple trials (e.g., n_trials=100). Optuna is a framework designed for automation and acceleration of optimization studies.

Sample code with scikit-learn [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](http://colab.research.google.com/github/optuna/optuna-examples/blob/main/quickstart.ipynb) ```python import optuna import sklearn # Define an objective function to be minimized. def objective(trial): # Invoke suggest methods of a Trial object to generate hyperparameters. regressor_name = trial.suggest_categorical("regressor", ["SVR", "RandomForest"]) if regressor_name == "SVR": svr_c = trial.suggest_float("svr_c", 1e-10, 1e10, log=True) regressor_obj = sklearn.svm.SVR(C=svr_c) else: rf_max_depth = trial.suggest_int("rf_max_depth", 2, 32) regressor_obj = sklearn.ensemble.RandomForestRegressor(max_depth=rf_max_depth) X, y = sklearn.datasets.fetch_california_housing(return_X_y=True) X_train, X_val, y_train, y_val = sklearn.model_selection.train_test_split(X, y, random_state=0) regressor_obj.fit(X_train, y_train) y_pred = regressor_obj.predict(X_val) error = sklearn.metrics.mean_squared_error(y_val, y_pred) return error # An objective value linked with the Trial object. study = optuna.create_study() # Create a new study. study.optimize(objective, n_trials=100) # Invoke optimization of the objective function. ```

[!NOTE] More examples can be found in optuna/optuna-examples.

The examples cover diverse problem setups such as multi-objective optimization, constrained optimization, pruning, and distributed optimization.

Installation

Optuna is available at the Python Package Index and on Anaconda Cloud.

```bash

PyPI

$ pip install optuna ```

```bash

Anaconda Cloud

$ conda install -c conda-forge optuna ```

[!IMPORTANT] Optuna supports Python 3.8 or newer.

Also, we provide Optuna docker images on DockerHub.

Integrations

Optuna has integration features with various third-party libraries. Integrations can be found in optuna/optuna-integration and the document is available here.

Supported integration libraries * [Catboost](https://github.com/optuna/optuna-examples/tree/main/catboost/catboost_pruning.py) * [Dask](https://github.com/optuna/optuna-examples/tree/main/dask/dask_simple.py) * [fastai](https://github.com/optuna/optuna-examples/tree/main/fastai/fastai_simple.py) * [Keras](https://github.com/optuna/optuna-examples/tree/main/keras/keras_integration.py) * [LightGBM](https://github.com/optuna/optuna-examples/tree/main/lightgbm/lightgbm_integration.py) * [MLflow](https://github.com/optuna/optuna-examples/tree/main/mlflow/keras_mlflow.py) * [PyTorch](https://github.com/optuna/optuna-examples/tree/main/pytorch/pytorch_simple.py) * [PyTorch Ignite](https://github.com/optuna/optuna-examples/tree/main/pytorch/pytorch_ignite_simple.py) * [PyTorch Lightning](https://github.com/optuna/optuna-examples/tree/main/pytorch/pytorch_lightning_simple.py) * [TensorBoard](https://github.com/optuna/optuna-examples/tree/main/tensorboard/tensorboard_simple.py) * [TensorFlow](https://github.com/optuna/optuna-examples/tree/main/tensorflow/tensorflow_estimator_integration.py) * [tf.keras](https://github.com/optuna/optuna-examples/tree/main/tfkeras/tfkeras_integration.py) * [Weights & Biases](https://github.com/optuna/optuna-examples/tree/main/wandb/wandb_integration.py) * [XGBoost](https://github.com/optuna/optuna-examples/tree/main/xgboost/xgboost_integration.py)

Web Dashboard

Optuna Dashboard is a real-time web dashboard for Optuna. You can check the optimization history, hyperparameter importance, etc. in graphs and tables. You don't need to create a Python script to call Optuna's visualization functions. Feature requests and bug reports are welcome!

optuna-dashboard

optuna-dashboard can be installed via pip:

shell $ pip install optuna-dashboard

[!TIP] Please check out the convenience of Optuna Dashboard using the sample code below.

Sample code to launch Optuna Dashboard Save the following code as `optimize_toy.py`. ```python import optuna def objective(trial): x1 = trial.suggest_float("x1", -100, 100) x2 = trial.suggest_float("x2", -100, 100) return x1**2 + 0.01 * x2**2 study = optuna.create_study(storage="sqlite:///db.sqlite3") # Create a new study with database. study.optimize(objective, n_trials=100) ``` Then try the commands below: ```shell # Run the study specified above $ python optimize_toy.py # Launch the dashboard based on the storage `sqlite:///db.sqlite3` $ optuna-dashboard sqlite:///db.sqlite3 ... Listening on http://localhost:8080/ Hit Ctrl-C to quit. ```

OptunaHub

OptunaHub is a feature-sharing platform for Optuna. You can use the registered features and publish your packages.

Use registered features

optunahub can be installed via pip:

```shell $ pip install optunahub

Install AutoSampler dependencies (CPU only is sufficient for PyTorch)

$ pip install cmaes scipy torch --extra-index-url https://download.pytorch.org/whl/cpu ```

You can load registered module with optunahub.load_module.

```python import optuna import optunahub

def objective(trial: optuna.Trial) -> float: x = trial.suggestfloat("x", -5, 5) y = trial.suggestfloat("y", -5, 5) return x2 + y2

module = optunahub.loadmodule(package="samplers/autosampler") study = optuna.createstudy(sampler=module.AutoSampler()) study.optimize(objective, ntrials=10)

print(study.besttrial.value, study.besttrial.params) ```

For more details, please refer to the optunahub documentation.

Publish your packages

You can publish your package via optunahub-registry. See the Tutorials for Contributors in OptunaHub.

Communication

Contribution

Any contributions to Optuna are more than welcome!

If you are new to Optuna, please check the good first issues. They are relatively simple, well-defined, and often good starting points for you to get familiar with the contribution workflow and other developers.

If you already have contributed to Optuna, we recommend the other contribution-welcome issues.

For general guidelines on how to contribute to the project, take a look at CONTRIBUTING.md.

Reference

If you use Optuna in one of your research projects, please cite our KDD paper "Optuna: A Next-generation Hyperparameter Optimization Framework":

BibTeX ```bibtex @inproceedings{akiba2019optuna, title={{O}ptuna: A Next-Generation Hyperparameter Optimization Framework}, author={Akiba, Takuya and Sano, Shotaro and Yanase, Toshihiko and Ohta, Takeru and Koyama, Masanori}, booktitle={The 25th ACM SIGKDD International Conference on Knowledge Discovery \& Data Mining}, pages={2623--2631}, year={2019} } ```

License

MIT License (see LICENSE).

Optuna uses the codes from SciPy and fdlibm projects (see LICENSETHIRDPARTY).

Owner

  • Name: optuna
  • Login: optuna
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.2.0
authors:
  - name: Preferred Networks, Inc.
title: "Optuna: A hyperparameter optimization framework"
url: "https://github.com/optuna/optuna"
preferred-citation:
  type: conference-paper
  authors:
    - family-names: "Akiba"
      given-names: "Takuya"
    - family-names: "Sano"
      given-names: "Shotaro"
    - family-names: "Yanase"
      given-names: "Toshihiko"
    - family-names: "Ohta"
      given-names: "Takeru"
    - family-names: "Koyama"
      given-names: "Masanori"
  doi: "10.1145/3292500.3330701"
  collection-title: "Proceedings of the 25th ACM SIGKDD international conference on knowledge discovery & data mining"
  start: 2623
  end: 2631
  title: "Optuna: A next-generation hyperparameter optimization framework"
  year: 2019

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 14,789
  • Total Committers: 302
  • Avg Commits per committer: 48.97
  • Development Distribution Score (DDS): 0.925
Past Year
  • Commits: 1,239
  • Committers: 57
  • Avg Commits per committer: 21.737
  • Development Distribution Score (DDS): 0.734
Top Committers
Name Email Commits
Toshihiko Yanase t****e@g****m 1,108
HideakiImamura i****a@m****p 877
Takeru Ohta p****8@g****m 793
Kento Nozawa k****w@k****p 769
hvy h****i@g****m 661
nabenabe0928 s****o@g****m 641
Makoto Hiramatsu h****t@k****p 556
c-bata c****t@c****k 545
Contramundum c****3@o****m 524
Masaki Kozuki m****4@g****m 465
Shinichi Hemmi 5****a 461
Naoto Mizuno n****o@p****p 406
Shotaro Sano s****o@p****p 398
Hiroki Takizawa c****t@h****e 382
himkt h****t@c****m 350
xadrianzetx x****x@g****m 337
harupy h****0@g****m 259
Takuya Akiba t****6@g****m 240
Yusuke Tsuzuku y****g@g****m 214
gen740 g****o@g****m 214
kaitos k****s@p****p 180
ytknzw y****w@g****m 169
Crissman c****n@p****p 167
keisuke-umezawa k****a@g****m 163
y0z y****z 143
Kenshin Abe a****n@g****m 139
norihitoishida n****a@g****m 126
PhilipMay e****o@g****m 115
bigbird555 k****x@g****p 112
wattlebirdaz_optiplex w****z@g****m 106
and 272 more...

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 454
  • Total pull requests: 1,623
  • Average time to close issues: 7 months
  • Average time to close pull requests: 8 days
  • Total issue authors: 268
  • Total pull request authors: 154
  • Average comments per issue: 3.85
  • Average comments per pull request: 2.4
  • Merged pull requests: 1,279
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 100
  • Pull requests: 703
  • Average time to close issues: 26 days
  • Average time to close pull requests: 5 days
  • Issue authors: 67
  • Pull request authors: 65
  • Average comments per issue: 0.81
  • Average comments per pull request: 1.65
  • Merged pull requests: 527
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • nabenabe0928 (23)
  • not522 (23)
  • HideakiImamura (23)
  • nzw0301 (17)
  • c-bata (11)
  • Alnusjaponica (10)
  • hrntsm (9)
  • toshihikoyanase (7)
  • contramundum53 (7)
  • kAIto47802 (6)
  • y0z (6)
  • knshnb (5)
  • keisuke-umezawa (4)
  • eukaryo (4)
  • bionicles (4)
Pull Request Authors
  • nabenabe0928 (246)
  • boringbyte (153)
  • not522 (107)
  • nzw0301 (104)
  • eukaryo (101)
  • c-bata (90)
  • HideakiImamura (74)
  • Alnusjaponica (58)
  • y0z (54)
  • sawa3030 (43)
  • porink0424 (38)
  • contramundum53 (36)
  • kAIto47802 (34)
  • toshihikoyanase (31)
  • gen740 (31)
Top Labels
Issue Labels
feature (146) stale (135) bug (131) contribution-welcome (78) code-fix (48) document (46) question (30) needs-discussion (30) good first issue (22) CI (9) enhancement (6) test (6) optuna.samplers (5) optuna.visualization (4) optuna.testing (2) description-checked (2) no-stale (2) other (1) compatibility (1) v3 (1) optuna.storages (1) optuna.trial (1) optuna.study (1) optuna.integration (1)
Pull Request Labels
code-fix (384) document (274) enhancement (135) CI (125) bug (115) feature (95) other (92) optuna.integration (74) optuna.samplers (63) compatibility (58) stale (54) optuna.visualization (47) test (31) optuna.storages (27) optuna.trial (17) optuna.importance (11) sprint-20250531 (11) optuna.testing (10) optuna.pruners (10) installation (7) needs-discussion (6) sprint-20221106 (4) v3 (4) optuna.study (3) sprint-20210227 (1) sprint-20200912 (1) sprint-20211031 (1) sprint-20220424 (1) sprint-20211219 (1) dependencies (1)

Dependencies

.github/workflows/checks.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/coverage.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3 composite
.github/workflows/dockerimage.yml actions
  • actions/checkout v3 composite
.github/workflows/mac-tests.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/performance-benchmarks-bayesmark.yml actions
  • actions/checkout v3 composite
  • actions/checkout master composite
  • actions/download-artifact v2 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • geekyeggo/delete-artifact v1 composite
.github/workflows/performance-benchmarks-kurobako.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
.github/workflows/performance-benchmarks-mo-kurobako.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
.github/workflows/performance-benchmarks-naslib.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
.github/workflows/pypi-publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/reviewdog.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • reviewdog/action-suggester v1 composite
.github/workflows/speed-benchmarks.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/sphinx-build.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
.github/workflows/stale.yml actions
  • actions/stale v6 composite
.github/workflows/tests-storage.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • mysql 5.7 docker
  • postgres 10.1-alpine docker
  • redis * docker
.github/workflows/tests-with-minimum-versions.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • redis * docker
.github/workflows/tests.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • redis * docker
.github/workflows/windows-tests.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • mpi4py/setup-mpi v1 composite
Dockerfile docker
  • python ${PYTHON_VERSION} build
pyproject.toml pypi
  • PyYAML *
  • alembic >=1.5.0
  • colorlog *
  • numpy *
  • packaging >=20.0
  • sqlalchemy >=1.3.0
  • tqdm *
.github/workflows/matplotlib-tests.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite