-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a tutorial demonstrating how to display plots in Optuna-Dashboard #81
Merged
nabenabe0928
merged 3 commits into
optuna:main
from
fusawa-yugo:fusawa-yugo/add-tutorial-doc
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Tutorials | ||
========= | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
plot-in-optuna-dashboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
Tutorial: How to Plot in Optuna-Dashboard | ||
========================================= | ||
|
||
In this tutorial, we will explain how to display plots in `Optuna-Dashboard <https://optuna-dashboard.readthedocs.io/en/latest/index.html>`_. | ||
|
||
`optuna_dashboard.save_plotly_graph_object <https://optuna-dashboard.readthedocs.io/en/latest/_generated/optuna_dashboard.save_plotly_graph_object.html#optuna_dashboard.save_plotly_graph_object>`__ can be used | ||
to integrate and display plots generated by Optunahub modules in Optuna-Dashboard. | ||
|
||
|
||
Preparation | ||
----------- | ||
|
||
First, ensure the necessary packages are installed by executing the following command: | ||
|
||
.. code-block:: console | ||
|
||
$ pip install optuna optunahub optuna-dashboard | ||
|
||
Example | ||
------- | ||
|
||
To illustrate an example, we use `The WFG Problem Collection <https://hub.optuna.org/benchmarks/wfg/>`__ and `Plot Pareto Front for Multiple Studies <https://hub.optuna.org/visualization/plot_pareto_front_multi/>`__. | ||
|
||
|
||
.. code-block:: python | ||
|
||
import optuna | ||
import optunahub | ||
from optuna_dashboard import save_plotly_graph_object | ||
|
||
wfg = optunahub.load_module("benchmarks/wfg") | ||
wfg4 = wfg.Problem(function_id=4, n_objectives=2, dimension=3, k=1) | ||
|
||
samplers = [ | ||
optuna.samplers.RandomSampler(), | ||
optuna.samplers.TPESampler(), | ||
optuna.samplers.NSGAIISampler(), | ||
] | ||
studies = [] | ||
|
||
for sampler in samplers: | ||
study = optuna.create_study( | ||
sampler=sampler, | ||
study_name=sampler.__class__.__name__, | ||
directions=wfg4.directions, | ||
storage="sqlite:///db.sqlite3", | ||
) | ||
study.optimize(wfg4, n_trials=100) | ||
studies.append(study) | ||
|
||
m = optunahub.load_module( | ||
"visualization/plot_pareto_front_multi" | ||
) | ||
fig = m.plot_pareto_front(studies) | ||
|
||
for study in studies: | ||
save_plotly_graph_object(study, fig) | ||
|
||
After running this code, launch the Optuna-Dashboard by the following command: | ||
|
||
.. code-block:: console | ||
|
||
$ optuna-dashboard sqlite:///db.sqlite3 | ||
|
||
Then, go to one of the study pages. | ||
You can see the plot in the dashboard like the image below. | ||
|
||
.. figure:: ./images/plot-in-optuna-dashboard.png | ||
:alt: Plot in Optuna-Dashboard | ||
:align: center | ||
:width: 800px | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a line saying that we have tutorials both for OptunaHub and OptunaHub Registry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only added tutorial for OptunaHub because tutorial of OptunaHub-Registry is already mentioned.