Skip to content

Commit

Permalink
Add doc-string
Browse files Browse the repository at this point in the history
  • Loading branch information
nabenabe0928 committed Aug 9, 2024
1 parent 95e1357 commit d6a202b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion basic_and_faq_usages/simple_artifact_store.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
"""
A simple example of Optuna Artifact Store.
In this example, we optimize coefficients (a, b) of a quadratic function:
f(x) = a * x**2 + b
The demo works as follows:
1. Create a dataset by ``create_dataset``,
2. For each trial, Optuna suggests a candidate of (a, b),
3. For each trial, plot the prediction,
4. Upload the prediction figure to the artifact store, and
5. After the optimization, check the prediction for best_trial using the download API.
"""

import os
import tempfile

Expand Down Expand Up @@ -42,7 +57,7 @@ def plot_predictions(a, b, trial, tmp_dir):
_, ax = plt.subplots()
x = np.linspace(-5, 5, 100)
ax.scatter(dataset["X"], dataset["Y"], label="Dataset", color="blue")
ax.plot(x, a * x**2 + b, label="Prediction", color="darkred")
ax.plot(x, a * x ** 2 + b, label="Prediction", color="darkred")
ax.set_title(f"a={a:.2f}, b={b:.2f}")
ax.grid()
ax.legend()
Expand Down

0 comments on commit d6a202b

Please sign in to comment.