-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval.py
146 lines (136 loc) · 5.67 KB
/
eval.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
import os
import matplotlib
from eval.cleaner import Cleaner
from eval.parser import SummaryToDetectorParser, SummariesToAverageParser
from eval.plotter import SummaryPlotter
from eval.summarize import Summarizer
def main():
matplotlib.set_loglevel("error")
show = False
cleaner = Cleaner(
read_root="results",
write_clean_root="results_clean",
write_repeats_root="results_periodic",
write_no_detections_root="results_no_detections",
)
cleaner.filter_results()
summarizer = Summarizer(read_root="results_clean", write_root="results_summarized")
summarizer.summarize()
print("Filtering and summaries complete")
# MTR ANALYSIS
print("\nAnalysing R² of acc/lpd and mtr")
parser = SummaryPlotter(
read_root="results_summarized", file="InsectsAbruptBalanced"
)
parser.plot_scatter_metrics_per_file(
x_metric="acc (ht-dd) (mean)", y_metric="mtr (mean)", show=show
)
parser.plot_scatter_metrics_per_file(
x_metric="lpd (ht) (mean)", y_metric="mtr (mean)", show=show
)
parser = SummaryPlotter(
read_root="results_summarized",
file="InsectsAbruptBalanced",
write_root="results_figures",
)
parser.plot_top_metric_boxes(metric="mtr (mean)", show=show)
parser = SummaryPlotter(
read_root="results_summarized", file="SineClusters"
)
parser.plot_scatter_metrics_per_file(
x_metric="acc (ht-dd) (mean)", y_metric="mtr (mean)", show=show
)
parser.plot_scatter_metrics_per_file(
x_metric="lpd (ht) (mean)", y_metric="mtr (mean)", show=show
)
parser = SummaryPlotter(
read_root="results_summarized", file="WaveformDrift2"
)
parser.plot_scatter_metrics_per_file(
x_metric="acc (ht-dd) (mean)", y_metric="mtr (mean)", show=show
)
parser.plot_scatter_metrics_per_file(
x_metric="lpd (ht) (mean)", y_metric="mtr (mean)", show=show
)
# LPD ANALYSIS
print("\nAnalysing R² of acc with Hoeffding tree and acc with Naive Bayes")
for file_ in sorted(os.listdir("results_summarized")):
parser = SummaryPlotter(
read_root="results_summarized", file=file_, write_root="results_figures"
)
parser.plot_scatter_metrics(
x_metric="lpd (ht) (mean)",
y_metric="lpd (nb) (mean)",
show=show,
print_r2=True,
)
print("\nAnalysing R² of lpd with Hoeffding tree and lpd with Naive Bayes")
for file_ in sorted(os.listdir("results_summarized")):
parser = SummaryPlotter(
read_root="results_summarized", file=file_, write_root="results_figures"
)
parser.plot_scatter_metrics(
x_metric="lpd (ht) (mean)",
y_metric="lpd (nb) (mean)",
show=show,
print_r2=True,
)
print("\nAnalysing R² of acc and lpd with Hoeffding tree")
for file_ in sorted(os.listdir("results_summarized")):
parser = SummaryPlotter(
read_root="results_summarized", file=file_, write_root="results_figures"
)
parser.plot_scatter_metrics(
x_metric="lpd (ht) (mean)",
y_metric="acc (ht-dd) (mean)",
show=show,
print_r2=True,
)
print(
"\nPlotting scatter plots of accuracy and lpd with number of detected drifts each"
)
for file_ in sorted(os.listdir("results_summarized")):
parser = SummaryPlotter(
read_root="results_summarized", file=file_, write_root="results_figures"
)
parser.plot_scatter_metrics(
x_metric="acc (ht-dd) (mean)",
y_metric="drifts (mean)",
markersize=26,
log_y=True,
show=show,
)
parser.plot_scatter_metrics(
x_metric="lpd (ht) (mean)",
y_metric="drifts (mean)",
markersize=26,
log_y=True,
show=show,
)
parser = SummaryToDetectorParser("results_summarized", "results_best")
parser.get_top_n_configurations("bndm", n_configs=10000, metric="lpd (ht)")
parser.get_top_n_configurations("csddm", n_configs=10000, metric="lpd (ht)")
parser.get_top_n_configurations("d3", n_configs=10000, metric="lpd (ht)")
parser.get_top_n_configurations("ibdd", n_configs=10000, metric="lpd (ht)")
parser.get_top_n_configurations("ocdd", n_configs=10000, metric="lpd (ht)")
parser.get_top_n_configurations("spll", n_configs=10000, metric="lpd (ht)")
parser.get_top_n_configurations("udetect", n_configs=10000, metric="lpd (ht)")
parser.get_top_n_configurations("bndm", n_configs=10000, metric="acc (ht-dd)")
parser.get_top_n_configurations("csddm", n_configs=10000, metric="acc (ht-dd)")
parser.get_top_n_configurations("d3", n_configs=10000, metric="acc (ht-dd)")
parser.get_top_n_configurations("ibdd", n_configs=10000, metric="acc (ht-dd)")
parser.get_top_n_configurations("ocdd", n_configs=10000, metric="acc (ht-dd)")
parser.get_top_n_configurations("spll", n_configs=10000, metric="acc (ht-dd)")
parser.get_top_n_configurations("udetect", n_configs=10000, metric="acc (ht-dd)")
parser = SummariesToAverageParser("results_summarized", "results_best")
detectors = ["bndm", "csddm", "d3", "ibdd", "ocdd", "spll", "udetect"]
all_counts = {}
for detector in detectors:
parser.get_average_rank_per_config(detector, metric="acc (ht-dd)")
counts = parser.get_average_rank_per_config(detector, metric="lpd (ht)")
all_counts[detector] = counts
plotter = SummaryPlotter("", "", "results_figures")
plotter.failure_bar_plot(all_counts, show=show)
print("\nEvaluation concluded")
if __name__ == "__main__":
main()