https://github.com/lucidfrontier45/optuna-async-helper
A Helper Library to run asynchronous optimization with Optuna
https://github.com/lucidfrontier45/optuna-async-helper
blackbox-optimization hyperparameter-tuning machinelearning optuna
Last synced: 3 months ago
JSON representation
A Helper Library to run asynchronous optimization with Optuna
- Host: GitHub
- URL: https://github.com/lucidfrontier45/optuna-async-helper
- Owner: lucidfrontier45
- License: mit
- Created: 2024-02-13T22:55:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-02T11:12:50.000Z (10 months ago)
- Last Synced: 2024-10-03T07:16:06.258Z (9 months ago)
- Topics: blackbox-optimization, hyperparameter-tuning, machinelearning, optuna
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Optuna Async Helper
A Helper Library for Optuna Async Optimization# Install
```bash
pip install optuna-async-helper
```# Usage
```python
import tempfilefrom optuna_async_helper import (
SearchSpace,
SearchSpec,
optimize,
create_journal_storage,
create_study,
)def rosenbrock(x: float, y: float, z: float) -> float:
return (z - x) ** 2 + 100 * (y - x**2) ** 2def test_optimizer():
search_space: SearchSpace = [
SearchSpec(var_name="x", domain_type="float", low=-5, high=5),
SearchSpec(var_name="y", domain_type="float", low=-5, high=5),
]
z = 0.5
initial_params = [
{"x": 0, "y": 0},
{"x": 1.0, "y": 0},
{"x": 0, "y": 1.0},
]with tempfile.TemporaryDirectory() as tempdir:
storage = create_journal_storage(f"{tempdir}/example.db")
study = create_study(
study_name="rosenbrock",
storage=storage,
)
study = optimize(
study,
objective_func=rosenbrock,
search_space=search_space,
initial_params=initial_params,
n_trials=10,
batch_size=32,
z=z,
)assert study.best_value < 1.0
assert abs(study.best_params["x"] - z) < 1.0
assert abs(study.best_params["y"] - z) < 1.0
```For more detail, please check `optimize` and `SearchSpec` definitions.
# Development
The project is managed by [uv](https://docs.astral.sh/uv/)