Skip to content

Commit

Permalink
Fix and clarify the tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
not522 committed May 22, 2024
1 parent 48f4127 commit 149d01f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions recipes/001_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ def objective(trial: optuna.trial.Trial) -> float:
# In this section, we show how to implement your own visualization function.
# If you want to implement a sampler rather than a visualization function, you can skip this section and move to the next section.
#
# You need to install `optuna` to implement your own sampler, and `optunahub` to use the template `SimpleSampler`.
# You need to install `optuna` to implement your own visualization function.
#
# .. code-block:: bash
#
# $ pip install optuna optunahub
# $ pip install optuna
#
# Next, define your own visualization function.
#
Expand All @@ -134,14 +134,14 @@ def objective(trial: optuna.trial.Trial) -> float:

def plot_optimizaiton_history(study: optuna.study.Study) -> go.Figure:
trials = study.trials
best_values = [trial.value for trial in trials]
best_values = [min(best_values[: i + 1]) for i in range(len(best_values))]
iteration = [i for i in range(len(trials))]
values = [trial.value for trial in trials]
best_values = [min(values[: i + 1]) for i in range(len(values))]
iterations = list(range(len(trials)))

fig = go.Figure()
fig.add_trace(
go.Scatter(
x=iteration,
x=iterations,
y=best_values,
mode="lines+markers",
)
Expand All @@ -156,8 +156,8 @@ def plot_optimizaiton_history(study: optuna.study.Study) -> go.Figure:

def plot_optimizaiton_history_matplotlib(study: optuna.study.Study) -> plt.Figure:
trials = study.trials
best_values = [trial.value for trial in trials]
best_values = [min(best_values[: i + 1]) for i in range(len(best_values))]
values = [trial.value for trial in trials]
best_values = [min(values[: i + 1]) for i in range(len(values))]

fig, ax = plt.subplots()
ax.set_title("Optimization history")
Expand Down Expand Up @@ -205,9 +205,9 @@ def plot_optimizaiton_history_matplotlib(study: optuna.study.Study) -> plt.Figur
#
# - `README.md`: A description of your algorithm. This file is used to create an `web page of OptunaHub <https://hub.optuna.org/>`_. Let me explain the format of the `README.md` file later.
# - `__init__.py`: An initialization file. This file must implement your algorithm or import its implementation from another file, e.g., `YOUR_ALGORITHM_NAME.py`.
# - `LICENSE`: A license file. This file must contain the license of your algorithm. It should be the MIT license in the alpha version.
# - `LICENSE`: A license file. This file must contain the license of your algorithm. It should be the MIT license in the alpha version of OptunaHub.
# - `images`: This is optional. A directory that contains images. The images in this directory will be used the `web page of OptunaHub <https://hub.optuna.org/>`_. `thumbnail.png` will be used as a thumbnail in the web page for visualization packages. Note that `README.md` can also refer to image files, e.g. `images/screenshot.png`, in this directory.
# - `requirements.txt`: This is optional. A file that contains the additional dependencies of your algorithm. If there are no additional dependencies, you do not need to create this file.
# - `requirements.txt`: This is optional. A file that contains the additional dependencies of your algorithm. If there are no additional dependencies other than Optuna and OptunaHub, you do not need to create this file.
# - `YOUR_ALGORITHM_NAME.py`: The implementation of your algorithm.
#
# `README.md` must contain the following sections:
Expand All @@ -230,7 +230,7 @@ def plot_optimizaiton_history_matplotlib(study: optuna.study.Study) -> plt.Figur
# - `description`: A brief description of the package. It should be a one-sentence summary of the package.
# - `tags`: The package tags. It should be a list of strings. The tags must include `sampler` or `visualization` depending on the type of the package. You can add other tags as needed. For example, "['sampler', 'LLM']".
# - `optuna_versions`: A list of Optuna versions that the package supports. It should be a list of strings. For example, "['3.5.0', '3.6.1']".
# - `license`: The license of the package. It should be a string. For example, `'MIT License'`. The license must be `MIT` in the alpha version.
# - `license`: The license of the package. It should be a string. For example, `'MIT License'`. The license must be `MIT` in the alpha version of OptunaHub.
#
# - `Class or Function Names` section that describes the classes or functions provided by the package. If you provide multiple classes or functions, you should list them in this section. Note that the section must be a markdown list. If you provide only one class or function, you can simply write the class or function name. Note that the documentation of the classes or functions must be written in their docstrings. If you want to refer to the documentation, please leave the source code link, or write them in the following `Others` section. For example:
#
Expand Down

0 comments on commit 149d01f

Please sign in to comment.