-
Notifications
You must be signed in to change notification settings - Fork 8
/
2021-11-23-runtime-benchmark-ssa.py
177 lines (160 loc) · 5.1 KB
/
2021-11-23-runtime-benchmark-ssa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/env python3
import logging
import random
import shutil
import sys
from typing import List, Tuple
import numpy as np
from durations import Duration
from timeeval import TimeEval, Datasets, TrainingType
from timeeval.constants import HPI_CLUSTER
from timeeval.remote import RemoteConfiguration
from timeeval.resource_constraints import ResourceConstraints, GB
from timeeval.utils.metrics import Metric
from timeeval_experiments.algorithm_configurator import AlgorithmConfigurator
from timeeval_experiments.algorithms import *
from timeeval_experiments.baselines import Baselines
# Setup logging
logging.basicConfig(
filename="timeeval.log",
filemode="a",
level=logging.INFO,
# force=True,
format="%(asctime)s %(levelname)6.6s - %(name)20.20s: %(message)s",
)
random.seed(42)
np.random.rand(42)
MAX_CONTAMINATION = 0.1
MIN_ANOMALIES = 1
def main():
dm = Datasets(HPI_CLUSTER.akita_benchmark_path, create_if_missing=False)
configurator = AlgorithmConfigurator(config_path="param-config.json")
# Select datasets and algorithms
datasets: List[Tuple[str, str]] = dm.select(
collection_name="SSA",
# max_contamination=MAX_CONTAMINATION, # ignore, bc. no dataset with contamination < 0.1; it's for all > 0.14!
min_anomalies=MIN_ANOMALIES,
)
print(f"Selecting {len(datasets)} datasets")
algorithms = [
arima(),
# autoencoder(), # exclude
bagel(),
cblof(),
cof(),
copod(),
# dae(), # exclude
dbstream(),
deepant(),
# deepnap(), # run later with less datasets
donut(),
dspot(),
dwt_mlead(),
eif(),
encdec_ad(),
# ensemble_gi(), # exclude
# fast_mcd(), # exclude
fft(),
generic_rf(),
generic_xgb(),
grammarviz3(),
hbos(),
health_esn(),
hif(),
hotsax(),
hybrid_knn(),
if_lof(),
iforest(),
img_embedding_cae(),
kmeans(),
knn(),
laser_dbn(),
left_stampi(),
lof(),
lstm_ad(),
# lstm_vae(), # exclude
median_method(),
# mscred(), # exclude
# mtad_gat(), # exclude
multi_hmm(),
norma(),
normalizing_flows(),
# novelty_svr(), # exclude
numenta_htm(),
ocean_wnn(),
omnianomaly(),
pcc(),
pci(),
phasespace_svm(),
pst(),
random_black_forest(),
robust_pca(),
s_h_esd(),
sand(),
# sarima(), # exclude
series2graph(),
sr(),
sr_cnn(),
ssa(),
stamp(),
stomp(),
# subsequence_fast_mcd(), # exclude
subsequence_if(),
subsequence_lof(),
tanogan(),
tarzan(),
telemanom(),
torsk(),
triple_es(),
ts_bitmap(),
valmod(),
Baselines.normal()
]
print(f"Selecting {len(algorithms)} algorithms")
print("Configuring algorithms...")
configurator.configure(algorithms, perform_search=False)
print("\nDatasets:")
print("=====================================================================================")
for collection in np.unique([c for (c, d) in datasets]):
print(collection)
cds = sorted([d for (c, d) in datasets if c == collection])
for cd in cds:
print(f" {cd}")
print("=====================================================================================\n\n")
print("\nParameter configurations:")
print("=====================================================================================")
for algo in algorithms:
print(algo.name)
for param in algo.param_config:
print(f" {param}")
print("=====================================================================================\n\n")
sys.stdout.flush()
cluster_config = RemoteConfiguration(
scheduler_host=HPI_CLUSTER.odin01,
worker_hosts=HPI_CLUSTER.nodes
)
limits = ResourceConstraints(
tasks_per_host=10,
task_cpu_limit=1.,
task_memory_limit=3*GB,
use_preliminary_model_on_train_timeout=True,
train_timeout=Duration("2 hours"),
execute_timeout=Duration("2 hours"),
)
timeeval = TimeEval(dm, datasets, algorithms,
repetitions=1,
distributed=True,
remote_config=cluster_config,
resource_constraints=limits,
skip_invalid_combinations=True,
force_dimensionality_match=False,
force_training_type_match=False,
metrics=[Metric.ROC_AUC, Metric.PR_AUC, Metric.AVERAGE_PRECISION, Metric.RANGE_PR_AUC],
)
# copy parameter configuration file to results folder
timeeval.results_path.mkdir(parents=True, exist_ok=True)
shutil.copy2(configurator.config_path, timeeval.results_path)
timeeval.run()
print(timeeval.get_results(aggregated=True, short=True))
if __name__ == "__main__":
main()