-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscore_all_predictors.py
94 lines (88 loc) · 4.33 KB
/
score_all_predictors.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
import anomaly_detection
import argparse
from collections import defaultdict
import os
import pandas as pd
parser = argparse.ArgumentParser(description='PyTorch RNN Anomaly Detection Model')
parser.add_argument('--prediction_window_size', type=int, default=1,
help='prediction_window_size')
parser.add_argument('--data', type=str, default='IMS_bearings_test2',
help='type of the dataset (ecg, gesture, power_demand, space_shuttle, respiration, nyc_taxi')
parser.add_argument('--filename', type=str, default='combinedfiles_s0.pkl',
help='filename of the dataset')
parser.add_argument('--save_fig', default=True,
help='save results as figures')
parser.add_argument('--compensate', action='store_true',
help='compensate anomaly score using anomaly score esimation')
parser.add_argument('--beta', type=float, default=1.0,
help='beta value for f-beta score')
parser.add_argument('--model', type=str, default="LSTM")
parser.add_argument('--device', type=str, default="cuda")
parser.add_argument('--use_SVR', action='store_true')
parser.add_argument('--learning_rate', type=float, default=0.0002)
parser.add_argument('--save_path', type=str, default='save')
parser.add_argument('--result_path', type=str, default='result')
args = parser.parse_args()
files = defaultdict()
files['IMS_bearings_test1']=("combinedfiles_s4.pkl",
"combinedfiles_s5.pkl",
"combinedfiles_s6.pkl",
"combinedfiles_s7.pkl")
files['IMS_bearings_test2']=(["combinedfiles_s0.pkl"])
files['IMS_bearings_test3']=(["combinedfiles_s2.pkl"])
files['FEMTO_bearings_1_1']=("combinedfiles_accel_s0.pkl",
"combinedfiles_accel_s1.pkl")
files['FEMTO_bearings_1_2']=("combinedfiles_accel_s0.pkl",
"combinedfiles_accel_s1.pkl")
files['FEMTO_bearings_2_1']=("combinedfiles_accel_s0.pkl",
"combinedfiles_accel_s1.pkl")
files['FEMTO_bearings_2_2']=("combinedfiles_accel_s0.pkl",
"combinedfiles_accel_s1.pkl")
files['Bearing2_3']=("Bearing2_3combinedfiles_accel_s0.pkl",
"Bearing2_3combinedfiles_accel_s1.pkl")
files['FEMTO_bearings_3_1']=("combinedfiles_accel_s0.pkl",
"combinedfiles_accel_s1.pkl")
files['FEMTO_bearings_3_2']=("combinedfiles_accel_s0.pkl",
"combinedfiles_accel_s1.pkl")
files['Bearing1_3']=("Bearing1_3combinedfiles_accel_s0.pkl",
"Bearing1_3combinedfiles_accel_s1.pkl")
files['Bearing1_4']=("Bearing1_4combinedfiles_accel_s0.pkl",
"Bearing1_4combinedfiles_accel_s1.pkl")
files['Bearing1_5']=("Bearing1_5combinedfiles_accel_s0.pkl",
"Bearing1_5combinedfiles_accel_s1.pkl")
files['Bearing1_6']=("Bearing1_6combinedfiles_accel_s0.pkl",
"Bearing1_6combinedfiles_accel_s1.pkl")
files['Bearing1_7']=("Bearing1_7combinedfiles_accel_s0.pkl",
"Bearing1_7combinedfiles_accel_s1.pkl")
files['Bearing2_4']=("Bearing2_4combinedfiles_accel_s0.pkl",
"Bearing2_4combinedfiles_accel_s1.pkl")
files['Bearing2_5']=("Bearing2_5combinedfiles_accel_s1.pkl",
"Bearing2_5combinedfiles_accel_s0.pkl")
files['Bearing2_6']=("Bearing2_6combinedfiles_accel_s0.pkl",
"Bearing2_6combinedfiles_accel_s1.pkl")
files['Bearing2_7']=("Bearing2_7combinedfiles_accel_s0.pkl",
"Bearing2_7combinedfiles_accel_s1.pkl")
files['Bearing3_3']=("Bearing3_3combinedfiles_accel_s0.pkl",
"Bearing3_3combinedfiles_accel_s1.pkl")
#CAUSED ERRORS:
# files['Bearing1_4']=(["Bearing1_4combinedfiles_accel_s1.pkl"])
# files['Bearing2_3']=("Bearing2_3combinedfiles_accel_s0.pkl",
# "Bearing2_3combinedfiles_accel_s1.pkl")
# files['Bearing2_5']=(["Bearing2_5combinedfiles_accel_s1.pkl"])
for dir, filelist in files.items():
for f in filelist:
args.data = dir
args.filename = f
if not os.path.exists('dataset/'+dir+'/labeled/test/'+f):
print("file does not exist:" + dir + "/" + f)
else:
try:
print("detecting " + dir + "/" + f)
anomaly_detection.main(args)
except RuntimeError as err:
print("EXCEPTION OCCURRED")
print(err)
with open("errlog_ad.txt",'a+') as f:
f.write(str(err))
f.write("\n\n")
print("scoring of all files completed")