optuna / optuna-dashboard

Real-time Web Dashboard for Optuna.
https://optuna-dashboard.readthedocs.io/en/latest/
Other
521 stars 86 forks source link

Boolean parameters not displaying in VS code extension #912

Closed tfoslid closed 2 months ago

tfoslid commented 3 months ago

Description

Boolean parameters not displaying correct in VS code extension.

Screenshot 2024-07-29 at 14 49 06

How to Reproduce

Using the getting started example: https://github.com/optuna/optuna-examples/blob/main/quickstart.ipynb

Edit the cell after: Optimize hyperparameters of the model

  1. Edit objective function to include bootstrap = trial.suggest_categorical("bootstrap", [True, False])
  2. Edit the random forest classifier run: clf = sklearn.ensemble.RandomForestClassifier(n_estimators=n_estimators, max_depth=max_depth, bootstrap=bootstrap)
  3. Add storage to study: study = optuna.create_study(direction="maximize", storage="sqlite:///optuna_optimizer.db")
  4. Run optimizer
  5. Right click: optuna_optimizer.py -> "open in Optuna Dashboard"

Alternativly run:

`

import sklearn.datasets
import sklearn.ensemble
import sklearn.model_selection
import optuna

def objective(trial):
    iris = sklearn.datasets.load_iris()

    n_estimators = trial.suggest_int("n_estimators", 2, 20)
    max_depth = int(trial.suggest_float("max_depth", 1, 32, log=True))
    bootstrap = trial.suggest_categorical("bootstrap", [True, False])

    clf = sklearn.ensemble.RandomForestClassifier(n_estimators=n_estimators, max_depth=max_depth, bootstrap=bootstrap)

    return sklearn.model_selection.cross_val_score(
        clf, iris.data, iris.target, n_jobs=-1, cv=3
    ).mean()

study = optuna.create_study(direction="maximize")
study.optimize(objective, n_trials=100)

trial = study.best_trial

print("Accuracy: {}".format(trial.value))
print("Best hyperparameters: {}".format(trial.params))

`

Python version

3.11.8

Optuna version

3.6.1

optuna-dashboard version or git revision

Optuna Dashboard v0.3.0

Web browser

No response

VS Code

Version: 1.91.1 (Universal) Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:07:54.982Z (2 wks ago) Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.5.0