-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_al.py
150 lines (135 loc) · 4.9 KB
/
run_al.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
import os
from models.non_meta import RandomForest, KNN, SVM, DecisionTree, LogisticRegression, GradientBoosting
from utils.plot import plot_all_graphs
from utils import read_pickle, run_non_meta_model
from model_params import common_params, knn_params, svm_params, randomforest_params, \
logisticregression_params, decisiontree_params, gradientboosting_params, meta_train, meta_test
if __name__ == '__main__':
# Set up the results directory
results_folder = './results'
if not os.path.exists(results_folder):
os.makedirs(results_folder)
print('No folder for results storage found')
print('Make folder to store results at')
else:
print('Found existing folder. All results will be stored at')
print(results_folder)
# Append the data to cv_stats or overwrite the current results
overwrite = common_params['cv_stats_overwrite']
cv_stats_dst = common_params['stats_path']
if os.path.exists(cv_stats_dst) and overwrite:
print('Overwriting the current cv_stats.pkl')
os.remove(cv_stats_dst)
# Listing the categories of experiments we are running
categories = ['category_3', 'category_4_i', 'category_4_ii', 'category_5_i', 'category_5_ii']
# Meta-models
# PLATIPUS
# platipus_train_params = {**common_params, **meta_params, **meta_train}
# params = platipus.initialize(["PLATIPUS"], platipus_train_params)
# platipus.main(params)
# platipus_test_params = {**common_params, **meta_params, **meta_test}
# params = platipus.initialize(["PLATIPUS"], platipus_test_params)
# platipus.main(params)
# Non-meta models
# KNN
base_model = KNN
model_params = knn_params
for category in categories:
run_non_meta_model(
base_model,
common_params,
model_params,
category
)
# SVM
base_model = SVM
model_params = svm_params
for category in categories:
if '4_ii' not in category and '5_ii' not in category:
# Use regular random drawn datasets for categories
# that have sufficient successful experiments for training
run_non_meta_model(
base_model,
common_params,
model_params,
category
)
else:
# Use random drawn datasets with at least one success for
# categories that few sufficient successful experiments for training
run_non_meta_model(
base_model,
common_params,
model_params,
category,
success=True
)
# DecisionTree
base_model = DecisionTree
model_params = decisiontree_params
for category in categories:
run_non_meta_model(
base_model,
common_params,
model_params,
category
)
# Random Forest
base_model = RandomForest
model_params = randomforest_params
for category in categories:
run_non_meta_model(
base_model,
common_params,
model_params,
category
)
# logistic Regression
base_model = LogisticRegression
model_params = logisticregression_params
for category in categories:
if '4_ii' not in category and '5_ii' not in category:
# Use regular random drawn datasets for categories
# that have sufficient successful experiments for training
run_non_meta_model(
base_model,
common_params,
model_params,
category
)
else:
# Use random drawn datasets with at least one success for
# categories that few sufficient successful experiments for training
run_non_meta_model(
base_model,
common_params,
model_params,
category,
success=True
)
# Gradient Boosting
base_model = GradientBoosting
model_params = gradientboosting_params
for category in categories:
if '4_ii' not in category and '5_ii' not in category:
# Use regular random drawn datasets for categories
# that have sufficient successful experiments for training
run_non_meta_model(
base_model,
common_params,
model_params,
category
)
else:
# Use random drawn datasets with at least one success for
# categories that few sufficient successful experiments for training
run_non_meta_model(
base_model,
common_params,
model_params,
category,
success=True
)
# Use cv_stats.pkl to plot all graphs
cv_stats = read_pickle(common_params['stats_path'])
plot_all_graphs(cv_stats)