-
Notifications
You must be signed in to change notification settings - Fork 1
/
summarize_results.py
71 lines (69 loc) · 1.87 KB
/
summarize_results.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
import numpy as np
import pandas as pd
import scipy.stats as stats
import sklearn.metrics as metrics
import matplotlib.pyplot as plt
import matplotlib
import pickle
import os
from collections import OrderedDict
from util import plot_roc
method_dict = {
'true': {
'name':'GT',
'style':(0, (3, 1, 1, 1, 1, 1)),
},
'rand': {
'name':'RND',
'style':'dotted',
},
'len': {
'name':'LEN',
'style':'dashdot',
},
'NH': {
'name':'PPOD',
'style':'dashed',
},
'CNH': {
'name':'CPPOD',
'style':'solid',
},
}
methods = ['rand', 'len', 'NH', 'CNH', 'true']
datasets = ['pois', 'gam']
outliers = ['commiss', 'omiss']
curves = [
{
'func': plot_roc,
'name': 'AUROC',
'x': 'FPR',
'y': 'TPR',
'filename': 'roc',
},
]
plot = True
matplotlib.rcParams.update({'font.size': 6})
results = []
for dataset in datasets:
for outlier in outliers:
folder = f'result/{dataset}/{outlier}'
for curve in curves:
if plot:
fig = plt.figure(figsize=(2.4,1.8))
for method in methods:
df = pd.read_csv(f'{folder}/{method}_0.1.csv')
auc = curve['func'](df['label'], df[f'score_{outlier}'], method_dict[method], plot)
results.append(OrderedDict({
'dataset': dataset,
'outlier': outlier,
'method': method_dict[method]['name'],
'metric': curve['name'],
'value': auc,
}))
if plot:
plt.xlabel(curve['x'])
plt.ylabel(curve['y'])
plt.legend()
filename = curve['filename']
fig.savefig(f'result/fig/{filename}_{dataset}_{outlier}.pdf', bbox_inches='tight')