From 82d256b7df5e4bf43f146399e240cab1b30241b1 Mon Sep 17 00:00:00 2001 From: c-bata Date: Thu, 15 Dec 2022 20:40:35 +0900 Subject: [PATCH] Update the getting started section of README --- README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 888ae44b..26310af4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Real-time dashboard for [Optuna](https://github.com/optuna/optuna). Code files were originally taken from [Goptuna](https://github.com/c-bata/goptuna). -## Getting Started +## Installation You can install optuna-dashboard via [PyPI](https://pypi.org/project/optuna-dashboard/) or [Anaconda Cloud](https://anaconda.org/conda-forge/optuna-dashboard). @@ -14,13 +14,34 @@ You can install optuna-dashboard via [PyPI](https://pypi.org/project/optuna-dash $ pip install optuna-dashboard ``` -And you can also install following optional dependencies to make optuna-dashboard faster. +Also you can install following optional dependencies to make optuna-dashboard faster. ```console $ pip install optuna-fast-fanova gunicorn ``` -Then please execute `optuna-dashboard` command with Optuna storage URL. +## Getting Started + +First, please specify the storage URL to persistent your study using the [RDB backend](https://optuna.readthedocs.io/en/stable/tutorial/20_recipes/001_rdb.html). + +```python +import optuna + +def objective(trial): + x = trial.suggest_float("x", -100, 100) + y = trial.suggest_categorical("y", [-1, 0, 1]) + return x**2 + y + +if __name__ == "__main__": + study = optuna.create_study( + storage="sqlite:///db.sqlite3", # Specify the storage URL here. + study_name="quadratic-simple" + ) + study.optimize(objective, n_trials=100) + print(f"Best value: {study.best_value} (params: {study.best_params})") +``` + +After running the above script, please execute the `optuna-dashboard` command with Optuna storage URL. ``` $ optuna-dashboard sqlite:///db.sqlite3