Skip to content

Commit 354efa4

Browse files
committed
[refactor] Format the repo
1 parent d5faf85 commit 354efa4

6 files changed

+86
-21
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ incumbents/
77
**/.pytest_cache
88
.coverage
99
figs/
10+
archive/
1011

1112
build/
1213
dist/

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175

176176
END OF TERMS AND CONDITIONS
177177

178-
Copyright 2022 AutoML Freiburg and contributors
178+
Copyright 2022 Anonymous authors
179179

180180
Licensed under the Apache License, Version 2.0 (the "License");
181181
you may not use this file except in compliance with the License.

plan.md

-14
This file was deleted.

run_experiment.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ run_tpe () {
1212

1313
for quantile in 0.10 0.15
1414
do
15-
cmd="${prefix} --warmstart False --metalearn False --quantile ${quantile}"
16-
echo $cmd
17-
$cmd
18-
echo `date '+%y/%m/%d %H:%M:%S'`
15+
# cmd="${prefix} --warmstart False --metalearn False --quantile ${quantile}"
16+
# echo $cmd
17+
# $cmd
18+
# echo `date '+%y/%m/%d %H:%M:%S'`
1919

20-
for warmstart in True False
20+
for warmstart in False # True
2121
do
2222
cmd="${prefix} --warmstart ${warmstart} --metalearn True --uniform_transform True --quantile ${quantile}"
2323
echo $cmd
@@ -39,7 +39,7 @@ run_bench () {
3939
seed=${1}
4040
bench_name=${2}
4141
dataset_name=${3}
42-
for opt_name in tpe only-warmstart rgpe-parego rgpe-ehvi tstr-parego tstr-ehvi
42+
for opt_name in tpe # only-warmstart rgpe-parego rgpe-ehvi tstr-parego tstr-ehvi
4343
do
4444
prefix="python run.py --exp_id ${seed} --opt_name ${opt_name} --bench_name ${bench_name} --dataset_name ${dataset_name}"
4545
if [[ "$opt_name" == "tpe" ]]
File renamed without changes.

viz/viz_dataset_dist.py

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
from typing import Dict
2+
import json
3+
import pickle
4+
5+
from fast_pareto import nondominated_rank
6+
7+
import matplotlib.pyplot as plt
8+
9+
import numpy as np
10+
11+
from targets.hpolib.api import DatasetChoices as HPOlibChoices
12+
from targets.nmt_bench.api import DatasetChoices as NMTChoices
13+
14+
15+
plt.rcParams["font.family"] = "Times New Roman"
16+
plt.rcParams["font.size"] = 18
17+
plt.rcParams["mathtext.fontset"] = "stix" # The setting of math font
18+
19+
20+
def get_nd_rank_for_hpolib(percentile: int) -> Dict[str, np.ndarray]:
21+
nd_rank = {}
22+
for dataset in HPOlibChoices:
23+
print(dataset.name)
24+
costs = pickle.load(open(f"targets/hpolib/metric_vals/{dataset.name}.pkl", "rb"))
25+
data = np.asarray([costs["valid_mse"], costs["runtime"]]).T
26+
nd_rank[dataset.name] = nondominated_rank(costs=data)
27+
28+
return nd_rank
29+
30+
31+
def get_nd_rank_for_nmt(percentile: int) -> Dict[str, np.ndarray]:
32+
nd_rank = {}
33+
for dataset in NMTChoices:
34+
costs = json.load(open(f"nmt-bench/{dataset.value}"))
35+
data = np.asarray([costs["bleu"], costs["decoding_time"]]).T
36+
nd_rank[dataset.name] = nondominated_rank(costs=data, larger_is_better_objectives=[0])
37+
38+
return nd_rank
39+
40+
41+
def plot_cum(ax: plt.Axes, nd_rank: Dict[str, np.ndarray], percentile: int, set_ylabel: bool) -> None:
42+
colors = ["red", "blue", "green", "purple"]
43+
for i, (k, v) in enumerate(nd_rank.items()):
44+
n_configs = v.size
45+
order = np.argsort(v)[:int(n_configs * percentile / 100)]
46+
cnt = np.zeros(n_configs)
47+
cnt[np.arange(n_configs)[order]] = 1
48+
if len(nd_rank) == 4:
49+
dataset_name = " ".join([s.capitalize() for s in k.split("_")])
50+
else:
51+
lang = {"so": "Somali", "sw": "Swahili", "tl": "Tagalog", "en": "English"}
52+
dataset_name = " to ".join([lang[s] for s in k.split("_")])
53+
ax.plot(np.arange(n_configs), np.cumsum(cnt), label=dataset_name, color=colors[i])
54+
55+
title = f"Cumulated count of Top-{percentile}% configuration"
56+
ax.set_title(title)
57+
ax.set_xlabel("Config indices")
58+
59+
if set_ylabel:
60+
ax.set_ylabel("Cumulated count")
61+
62+
ax.legend()
63+
ax.grid()
64+
65+
66+
if __name__ == "__main__":
67+
_, axes = plt.subplots(
68+
figsize=(20, 5),
69+
ncols=2,
70+
gridspec_kw={"wspace": 0.1},
71+
)
72+
nd_rank = get_nd_rank_for_hpolib(percentile=1)
73+
plot_cum(axes[0], nd_rank, percentile=1, set_ylabel=True)
74+
75+
nd_rank = get_nd_rank_for_nmt(percentile=5)
76+
plot_cum(axes[1], nd_rank, percentile=5, set_ylabel=False)
77+
78+
plt.savefig("figs/dataset-dist.pdf", bbox_inches="tight")

0 commit comments

Comments
 (0)