-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRISE.py
More file actions
92 lines (71 loc) · 2.31 KB
/
RISE.py
File metadata and controls
92 lines (71 loc) · 2.31 KB
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
from sklearn.metrics import accuracy_score, f1_score, confusion_matrix
from sklearn.model_selection import cross_val_predict, KFold
import sklearn
import numpy as np
import os
import sys
import time
# define a list of datasets
datasets = [
"Control_charts",
"ETCHING_Multivar",
"Hydraulic_systems_10HZ_Multivar",
"Gas_sensors_home_activity",
"CWRU_12k_DE_univar",
"CWRU_12k_DE_multivar",
"CWRU_12k_FE_univar",
"CWRU_12k_FE_multivar",
"CWRU_48k_DE_univar",
"CWRU_48k_DE_multivar",
"Hydraulic_systems_100HZ_Multivar",
"PHM2022_Multivar",
"PHM2022_Univar_PIN",
"PHM2022_Univar_PO",
"PHM2022_Univar_PDIN",
"MFPT_48KHZ_Univar",
"MFPT_96KHZ_Univar",
"PADERBORN_64KHZ_Univar",
"PADERBORN_4KHZ_Univar",
"PADERBORN_64KHZ_Multivar",
"PADERBORN_4KHZ_Multivar",
"BEARING_Univar",
]
#datasets = ["Control_charts", "PHM2022_Multivar", "PHM2022_Univar_PDIN"]
datasets_path = "../datasets"
print(f"We are going to work on {len(datasets)} datasets!")
for dataset in datasets:
Dataset_name = dataset + "_Dataset"
Dataset = np.load(datasets_path + "/" + Dataset_name + ".npy")
print(Dataset.shape)
Labels_name = dataset + "_Labels"
Labels = np.load(datasets_path + "/" + Labels_name + ".npy")
# change this directory for your machine
root_dir = './'
# define a list of algorithms
algorirhms_path = "./classifiers"
from classifiers import RISE_module
# define the number of folds
n_folds = 5
# perform cross-validation for each dataset and algorithm combination
for dataset in datasets:
Dataset_name = dataset + "_Dataset"
Dataset = np.load(datasets_path + "/" + Dataset_name + ".npy")
start = time.time() ##Start timing
print(f"Starting to work on {Dataset_name} at {start}")
Labels_name = dataset + "_Labels"
Labels = np.load(datasets_path + "/" + Labels_name + ".npy")
# Create a folder for results
results_path = root_dir + "Results/" + Dataset_name
if os.path.exists(results_path):
pass
else:
try:
os.makedirs(results_path)
except:
# in case another machine created the path meanwhile !:(
pass
#Run The RISE Module
RISE_module.RISE(results_path, Dataset_name, Dataset, Labels, nb_folds=n_folds,
n_estimators = 200,
n_jobs=10)
print(f"Working on {Dataset_name} finished successfully!")