{"id":13472142,"url":"https://github.com/optuna/optuna","last_synced_at":"2025-05-12T18:30:27.787Z","repository":{"id":37382528,"uuid":"122299416","full_name":"optuna/optuna","owner":"optuna","description":"A hyperparameter optimization framework","archived":false,"fork":false,"pushed_at":"2025-05-02T05:41:42.000Z","size":20816,"stargazers_count":11869,"open_issues_count":66,"forks_count":1090,"subscribers_count":117,"default_branch":"master","last_synced_at":"2025-05-05T15:56:25.907Z","etag":null,"topics":["distributed","hacktoberfest","hyperparameter-optimization","machine-learning","parallel","python"],"latest_commit_sha":null,"homepage":"https://optuna.org","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/optuna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"optuna"}},"created_at":"2018-02-21T06:12:56.000Z","updated_at":"2025-05-05T02:13:04.000Z","dependencies_parsed_at":"2024-05-31T09:58:00.643Z","dependency_job_id":"3f6954f3-1b7b-4a32-b401-594ec22e8011","html_url":"https://github.com/optuna/optuna","commit_stats":{"total_commits":13886,"total_committers":331,"mean_commits":41.95166163141994,"dds":0.9205674780354314,"last_synced_commit":"287df113c293d16c9a789457541ddbe47f6736fb"},"previous_names":["pfnet/optuna"],"tags_count":73,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optuna%2Foptuna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optuna%2Foptuna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optuna%2Foptuna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optuna%2Foptuna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/optuna","download_url":"https://codeload.github.com/optuna/optuna/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253797824,"owners_count":21965967,"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":["distributed","hacktoberfest","hyperparameter-optimization","machine-learning","parallel","python"],"created_at":"2024-07-31T16:00:52.315Z","updated_at":"2025-05-12T18:30:27.754Z","avatar_url":"https://github.com/optuna.png","language":"Python","readme":"\u003cdiv align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/optuna/optuna/master/docs/image/optuna-logo.png\" width=\"800\"/\u003e\u003c/div\u003e\n\n# Optuna: A hyperparameter optimization framework\n\n[![Python](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org)\n[![pypi](https://img.shields.io/pypi/v/optuna.svg)](https://pypi.python.org/pypi/optuna)\n[![conda](https://img.shields.io/conda/vn/conda-forge/optuna.svg)](https://anaconda.org/conda-forge/optuna)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/optuna/optuna)\n[![Read the Docs](https://readthedocs.org/projects/optuna/badge/?version=stable)](https://optuna.readthedocs.io/en/stable/)\n[![Codecov](https://codecov.io/gh/optuna/optuna/branch/master/graph/badge.svg)](https://codecov.io/gh/optuna/optuna)\n\n:link: [**Website**](https://optuna.org/)\n| :page_with_curl: [**Docs**](https://optuna.readthedocs.io/en/stable/)\n| :gear: [**Install Guide**](https://optuna.readthedocs.io/en/stable/installation.html)\n| :pencil: [**Tutorial**](https://optuna.readthedocs.io/en/stable/tutorial/index.html)\n| :bulb: [**Examples**](https://github.com/optuna/optuna-examples)\n| [**Twitter**](https://twitter.com/OptunaAutoML)\n| [**LinkedIn**](https://www.linkedin.com/showcase/optuna/)\n| [**Medium**](https://medium.com/optuna)\n\n*Optuna* is an automatic hyperparameter optimization software framework, particularly designed\nfor machine learning. It features an imperative, *define-by-run* style user API. Thanks to our\n*define-by-run* API, the code written with Optuna enjoys high modularity, and the user of\nOptuna can dynamically construct the search spaces for the hyperparameters.\n\n## :loudspeaker: News\n\u003c!-- TODO: when you add a new line, please delete the oldest line --\u003e\n* **Apr 14, 2025**: Optuna 4.3.0 are out! Check out [the release note](https://github.com/optuna/optuna/releases/tag/v4.3.0) for details.\n* **Mar 24, 2025**: A new article [Distributed Optimization in Optuna and gRPC Storage Proxy](https://medium.com/optuna/distributed-optimization-in-optuna-and-grpc-storage-proxy-08db83f1d608) has been published.\n* **Mar 11, 2025**: A new article [[Optuna v4.2] Gaussian Process-Based Sampler Can Now Handle Inequality Constraints](https://medium.com/optuna/optuna-v4-2-gaussian-process-based-sampler-can-now-handle-inequality-constraints-a4f68e8ee810) has been published.\n* **Feb 17, 2025**: A new article [SMAC3 Registered on OptunaHub](https://medium.com/optuna/smac3-registered-on-optunahub-4fb9e90855cb) has been published.\n* **Jan 22, 2025**: A new article [OptunaHub Benchmarks: A New Feature to Use/Register Various Benchmark Problems](https://medium.com/optuna/optunahub-benchmarks-a-new-feature-to-use-register-various-benchmark-problems-694401524ce0) has been published.\n* **Jan 20, 2025**: Optuna 4.2.0 and OptunaHub 0.2.0 are out! Try the newest Optuna and OptunaHub! Check out [the release note](https://github.com/optuna/optuna/releases/tag/v4.2.0) for details.\n\n## :fire: Key Features\n\nOptuna has modern functionalities as follows:\n\n- [Lightweight, versatile, and platform agnostic architecture](https://optuna.readthedocs.io/en/stable/tutorial/10_key_features/001_first.html)\n  - Handle a wide variety of tasks with a simple installation that has few requirements.\n- [Pythonic search spaces](https://optuna.readthedocs.io/en/stable/tutorial/10_key_features/002_configurations.html)\n  - Define search spaces using familiar Python syntax including conditionals and loops.\n- [Efficient optimization algorithms](https://optuna.readthedocs.io/en/stable/tutorial/10_key_features/003_efficient_optimization_algorithms.html)\n  - Adopt state-of-the-art algorithms for sampling hyperparameters and efficiently pruning unpromising trials.\n- [Easy parallelization](https://optuna.readthedocs.io/en/stable/tutorial/10_key_features/004_distributed.html)\n  - Scale studies to tens or hundreds of workers with little or no changes to the code.\n- [Quick visualization](https://optuna.readthedocs.io/en/stable/tutorial/10_key_features/005_visualization.html)\n  - Inspect optimization histories from a variety of plotting functions.\n\n\n## Basic Concepts\n\nWe use the terms *study* and *trial* as follows:\n\n- Study: optimization based on an objective function\n- Trial: a single execution of the objective function\n\nPlease refer to the sample code below. The goal of a *study* is to find out the optimal set of\nhyperparameter values (e.g., `regressor` and `svr_c`) through multiple *trials* (e.g.,\n`n_trials=100`). Optuna is a framework designed for automation and acceleration of\noptimization *studies*.\n\n\u003cdetails open\u003e\n\u003csummary\u003eSample code with scikit-learn\u003c/summary\u003e\n\n[![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)\n\n```python\nimport ...\n\n# Define an objective function to be minimized.\ndef objective(trial):\n\n    # Invoke suggest methods of a Trial object to generate hyperparameters.\n    regressor_name = trial.suggest_categorical('regressor', ['SVR', 'RandomForest'])\n    if regressor_name == 'SVR':\n        svr_c = trial.suggest_float('svr_c', 1e-10, 1e10, log=True)\n        regressor_obj = sklearn.svm.SVR(C=svr_c)\n    else:\n        rf_max_depth = trial.suggest_int('rf_max_depth', 2, 32)\n        regressor_obj = sklearn.ensemble.RandomForestRegressor(max_depth=rf_max_depth)\n\n    X, y = sklearn.datasets.fetch_california_housing(return_X_y=True)\n    X_train, X_val, y_train, y_val = sklearn.model_selection.train_test_split(X, y, random_state=0)\n\n    regressor_obj.fit(X_train, y_train)\n    y_pred = regressor_obj.predict(X_val)\n\n    error = sklearn.metrics.mean_squared_error(y_val, y_pred)\n\n    return error  # An objective value linked with the Trial object.\n\nstudy = optuna.create_study()  # Create a new study.\nstudy.optimize(objective, n_trials=100)  # Invoke optimization of the objective function.\n```\n\u003c/details\u003e\n\n\u003e [!NOTE]\n\u003e More examples can be found in [optuna/optuna-examples](https://github.com/optuna/optuna-examples).\n\u003e\n\u003e The examples cover diverse problem setups such as multi-objective optimization, constrained optimization, pruning, and distributed optimization.\n\n## Installation\n\nOptuna is available at [the Python Package Index](https://pypi.org/project/optuna/) and on [Anaconda Cloud](https://anaconda.org/conda-forge/optuna).\n\n```bash\n# PyPI\n$ pip install optuna\n```\n\n```bash\n# Anaconda Cloud\n$ conda install -c conda-forge optuna\n```\n\n\u003e [!IMPORTANT]\n\u003e Optuna supports Python 3.8 or newer.\n\u003e\n\u003e Also, we provide Optuna docker images on [DockerHub](https://hub.docker.com/r/optuna/optuna).\n\n## Integrations\n\nOptuna has integration features with various third-party libraries. Integrations can be found in [optuna/optuna-integration](https://github.com/optuna/optuna-integration) and the document is available [here](https://optuna-integration.readthedocs.io/en/stable/index.html).\n\n\u003cdetails\u003e\n\u003csummary\u003eSupported integration libraries\u003c/summary\u003e\n\n* [Catboost](https://github.com/optuna/optuna-examples/tree/main/catboost/catboost_pruning.py)\n* [Dask](https://github.com/optuna/optuna-examples/tree/main/dask/dask_simple.py)\n* [fastai](https://github.com/optuna/optuna-examples/tree/main/fastai/fastai_simple.py)\n* [Keras](https://github.com/optuna/optuna-examples/tree/main/keras/keras_integration.py)\n* [LightGBM](https://github.com/optuna/optuna-examples/tree/main/lightgbm/lightgbm_integration.py)\n* [MLflow](https://github.com/optuna/optuna-examples/tree/main/mlflow/keras_mlflow.py)\n* [PyTorch](https://github.com/optuna/optuna-examples/tree/main/pytorch/pytorch_simple.py)\n* [PyTorch Ignite](https://github.com/optuna/optuna-examples/tree/main/pytorch/pytorch_ignite_simple.py)\n* [PyTorch Lightning](https://github.com/optuna/optuna-examples/tree/main/pytorch/pytorch_lightning_simple.py)\n* [TensorBoard](https://github.com/optuna/optuna-examples/tree/main/tensorboard/tensorboard_simple.py)\n* [TensorFlow](https://github.com/optuna/optuna-examples/tree/main/tensorflow/tensorflow_estimator_integration.py)\n* [tf.keras](https://github.com/optuna/optuna-examples/tree/main/tfkeras/tfkeras_integration.py)\n* [Weights \u0026 Biases](https://github.com/optuna/optuna-examples/tree/main/wandb/wandb_integration.py)\n* [XGBoost](https://github.com/optuna/optuna-examples/tree/main/xgboost/xgboost_integration.py)\n\u003c/details\u003e\n\n## Web Dashboard\n\n[Optuna Dashboard](https://github.com/optuna/optuna-dashboard) is a real-time web dashboard for Optuna.\nYou can check the optimization history, hyperparameter importance, etc. in graphs and tables.\nYou don't need to create a Python script to call [Optuna's visualization](https://optuna.readthedocs.io/en/stable/reference/visualization/index.html) functions.\nFeature requests and bug reports are welcome!\n\n![optuna-dashboard](https://user-images.githubusercontent.com/5564044/204975098-95c2cb8c-0fb5-4388-abc4-da32f56cb4e5.gif)\n\n`optuna-dashboard` can be installed via pip:\n\n```shell\n$ pip install optuna-dashboard\n```\n\n\u003e [!TIP]\n\u003e Please check out the convenience of Optuna Dashboard using the sample code below.\n\n\u003cdetails\u003e\n\u003csummary\u003eSample code to launch Optuna Dashboard\u003c/summary\u003e\n\nSave the following code as `optimize_toy.py`.\n\n```python\nimport optuna\n\n\ndef objective(trial):\n    x1 = trial.suggest_float(\"x1\", -100, 100)\n    x2 = trial.suggest_float(\"x2\", -100, 100)\n    return x1 ** 2 + 0.01 * x2 ** 2\n\n\nstudy = optuna.create_study(storage=\"sqlite:///db.sqlite3\")  # Create a new study with database.\nstudy.optimize(objective, n_trials=100)\n```\n\nThen try the commands below:\n\n```shell\n# Run the study specified above\n$ python optimize_toy.py\n\n# Launch the dashboard based on the storage `sqlite:///db.sqlite3`\n$ optuna-dashboard sqlite:///db.sqlite3\n...\nListening on http://localhost:8080/\nHit Ctrl-C to quit.\n```\n\n\u003c/details\u003e\n\n\n## OptunaHub\n\n[OptunaHub](https://hub.optuna.org/) is a feature-sharing platform for Optuna.\nYou can use the registered features and publish your packages.\n\n### Use registered features\n\n`optunahub` can be installed via pip:\n\n```shell\n$ pip install optunahub\n# Install AutoSampler dependencies (CPU only is sufficient for PyTorch)\n$ pip install cmaes scipy torch --extra-index-url https://download.pytorch.org/whl/cpu\n```\n\nYou can load registered module with `optunahub.load_module`.\n\n```python\nimport optuna\nimport optunahub\n\n\ndef objective(trial: optuna.Trial) -\u003e float:\n    x = trial.suggest_float(\"x\", -5, 5)\n    y = trial.suggest_float(\"y\", -5, 5)\n    return x**2 + y**2\n\n\nmodule = optunahub.load_module(package=\"samplers/auto_sampler\")\nstudy = optuna.create_study(sampler=module.AutoSampler())\nstudy.optimize(objective, n_trials=10)\n\nprint(study.best_trial.value, study.best_trial.params)\n```\n\nFor more details, please refer to [the optunahub documentation](https://optuna.github.io/optunahub/).\n\n### Publish your packages\n\nYou can publish your package via [optunahub-registry](https://github.com/optuna/optunahub-registry).\nSee the [Tutorials for Contributors](https://optuna.github.io/optunahub/tutorials_for_contributors.html) in OptunaHub.\n\n\n## Communication\n\n- [GitHub Discussions] for questions.\n- [GitHub Issues] for bug reports and feature requests.\n\n[GitHub Discussions]: https://github.com/optuna/optuna/discussions\n[GitHub issues]: https://github.com/optuna/optuna/issues\n\n\n## Contribution\n\nAny contributions to Optuna are more than welcome!\n\nIf you are new to Optuna, please check the [good first issues](https://github.com/optuna/optuna/labels/good%20first%20issue). They are relatively simple, well-defined, and often good starting points for you to get familiar with the contribution workflow and other developers.\n\nIf you already have contributed to Optuna, we recommend the other [contribution-welcome issues](https://github.com/optuna/optuna/labels/contribution-welcome).\n\nFor general guidelines on how to contribute to the project, take a look at [CONTRIBUTING.md](./CONTRIBUTING.md).\n\n\n## Reference\n\nIf you use Optuna in one of your research projects, please cite [our KDD paper](https://doi.org/10.1145/3292500.3330701) \"Optuna: A Next-generation Hyperparameter Optimization Framework\":\n\n\u003cdetails open\u003e\n\u003csummary\u003eBibTeX\u003c/summary\u003e\n\n```bibtex\n@inproceedings{akiba2019optuna,\n  title={{O}ptuna: A Next-Generation Hyperparameter Optimization Framework},\n  author={Akiba, Takuya and Sano, Shotaro and Yanase, Toshihiko and Ohta, Takeru and Koyama, Masanori},\n  booktitle={The 25th ACM SIGKDD International Conference on Knowledge Discovery \\\u0026 Data Mining},\n  pages={2623--2631},\n  year={2019}\n}\n```\n\u003c/details\u003e\n\n\n## License\n\nMIT License (see [LICENSE](./LICENSE)).\n\nOptuna uses the codes from SciPy and fdlibm projects (see [LICENSE_THIRD_PARTY](./LICENSE_THIRD_PARTY)).\n","funding_links":["https://github.com/sponsors/optuna"],"categories":["Python","🎯 Tool Categories","Optimization","AutoML","参数优化","\u003cspan id=\"head30\"\u003e3.4. Bayesian Inference\u003c/span\u003e","Profiling","Machine Learning Framework","Scheduling","超参数优化和AutoML","🤖 Machine Learning \u0026 AI","语言资源库","Libraries","The Data Science Toolbox","📋 Contents","Python Packages"],"sub_categories":["🛠️ AutoML \u0026 Model Training","Others","Profiling","\u003cspan id=\"head36\"\u003e3.4.6. Bayesian Optimization\u003c/span\u003e","Hyperparameter Search \u0026 Gradient-Free Optimization","General-Purpose Machine Learning","Tools","python","Miscellaneous Tools","NLP","🧬 1. Core Frameworks \u0026 Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptuna%2Foptuna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptuna%2Foptuna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptuna%2Foptuna/lists"}