Skip to content

Commit 1497b6d

Browse files
authored
Merge pull request #317 from nabenabe0928/add-eaf-image
Add eaf image
2 parents f317265 + 6f0c9fd commit 1497b6d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

package/visualization/plot_empirical_attainment_surface/README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ This package provides empirical attainment surface implementation based on [the
1717

1818
The details of empirical attainment surface are available in [`Python Tool for Visualizing Variability of Pareto Fronts over Multiple Runs`](https://arxiv.org/abs/2305.08852).
1919

20-
![Empirical Attainment Surface](images/demo.png)
21-
2220
## APIs
2321

2422
- `plot_empirical_attainment_surface(study_list: list[optuna.Study], attainment_ratios: list[int], ax: plt.Axes | None = None, color: str | None = None, label: str | None = None, linestyle: str | None = None, marker: str | None = None, log_scale_inds: list[int] | None = None, **ax_plot_kwargs)`
@@ -52,6 +50,8 @@ $ pip install optuna matplotlib
5250

5351
## Example
5452

53+
![Empirical Attainment Surface](images/demo.png)
54+
5555
**Example**
5656

5757
```python
@@ -61,14 +61,17 @@ import matplotlib.pyplot as plt
6161
import optuna
6262
import optunahub
6363

64+
plt.rcParams["font.family"] = "Times New Roman"
65+
plt.rcParams["font.size"] = 18
66+
6467

6568
def objective(trial: optuna.Trial) -> tuple[float, float]:
6669
x = trial.suggest_float("x", -5, 5)
6770
y = trial.suggest_float("y", -5, 5)
6871
return x**2 + y**2, (x - 2)**2 + (y - 2)**2
6972

7073
multiple_study_list = []
71-
for sampler_cls in [optuna.samplers.RandomSampler, optuna.samplers.TPESampler]:
74+
for sampler_cls in [optuna.samplers.RandomSampler, optuna.samplers.TPESampler, optuna.samplers.GPSampler]:
7275
study_list = []
7376
for seed in range(10):
7477
sampler = sampler_cls(seed=seed)
@@ -80,10 +83,18 @@ for sampler_cls in [optuna.samplers.RandomSampler, optuna.samplers.TPESampler]:
8083
plot_multiple_empirical_attainment_surfaces = optunahub.load_module(
8184
"visualization/plot_empirical_attainment_surface"
8285
).plot_multiple_empirical_attainment_surfaces
86+
_, ax = plt.subplots(figsize=(8, 6))
8387
ax = plot_multiple_empirical_attainment_surfaces(
84-
multiple_study_list, attainment_ratios=[0.25, 0.5, 0.75], labels=["Random", "TPE"]
88+
multiple_study_list,
89+
ax=ax,
90+
attainment_ratios=[0.25, 0.5, 0.75],
91+
labels=["RandomSampler", "TPESampler", "GPSampler"],
92+
colors=["gray", "darkred", "blue"],
8593
)
86-
plt.show()
94+
ax.set_xlabel("Objective 1")
95+
ax.set_ylabel("Objective 2")
96+
ax.grid()
97+
plt.savefig("demo.png", bbox_inches="tight")
8798
```
8899

89100
## Others
5.93 KB
Loading

0 commit comments

Comments
 (0)