-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
526 lines (345 loc) · 23.9 KB
/
main.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.impute import KNNImputer
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import MinMaxScaler
from sklearn.preprocessing import MaxAbsScaler
from sklearn.preprocessing import RobustScaler
from sklearn.preprocessing import QuantileTransformer
from sklearn.preprocessing import PowerTransformer
from sklearn.preprocessing import Normalizer
from sklearn.preprocessing import OneHotEncoder
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import confusion_matrix
#import dataset
file = "framingham.csv"
dataset = pd.read_csv(file, sep=";")
dataset["male"].fillna(9999, inplace=True)
dataset["education"].fillna(9999, inplace=True)
dataset["currentSmoker"].fillna(9999, inplace=True)
dataset["BPMeds"].fillna(9999, inplace=True)
dataset["prevalentStroke"].fillna(9999, inplace=True)
dataset["prevalentHyp"].fillna(9999, inplace=True)
dataset["diabetes"].fillna(9999, inplace=True)
dataset["age"].fillna(999, inplace=True)
dataset["totChol"].fillna(999, inplace=True)
dataset["sysBP"].fillna(999, inplace=True)
dataset["diaBP"].fillna(999, inplace=True)
dataset["BMI"].fillna(999, inplace=True)
dataset["heartRate"].fillna(999, inplace=True)
dataset["glucose"].fillna(999, inplace=True)
dataset["cigsPerDay"].fillna(999, inplace=True)
X = dataset.iloc[:, 0:15].values
Y = dataset.iloc[:,-1 ].values
imputer_categorical = KNNImputer(missing_values=9999, n_neighbors=1)
imputer_ordinal = KNNImputer(missing_values=999, n_neighbors=20)
# for feature evaluating with boxplot
X = imputer_categorical.fit_transform(X)
X = imputer_ordinal.fit_transform(X)
X = pd.DataFrame(X, columns=["male", "age", "education", "currentSmoker", "cigsPerDay", "BPMeds", "prevalentStroke", "prevalentHyp", "diabetes", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"])
stand_standardScaler = StandardScaler()
stand_MinMaxScaler = MinMaxScaler()
stand_MaxAbsScaler = MaxAbsScaler()
stand_RobustScaler = RobustScaler()
stand_quantileTransformNormal = QuantileTransformer(output_distribution='normal')
stand_quantileTransform_Uniform = QuantileTransformer(output_distribution='uniform')
stand_Power = PowerTransformer()
stand_normalizer = Normalizer()
enc = OneHotEncoder(handle_unknown='ignore')
enc_male = pd.DataFrame(enc.fit_transform(X[["male"]]).toarray())
X = X.drop("male", axis=1)
enc_education = pd.DataFrame(enc.fit_transform(X[["education"]]).toarray())
X = X.drop("education", axis=1)
enc_currentSmoker = pd.DataFrame(enc.fit_transform(X[["currentSmoker"]]).toarray())
X = X.drop("currentSmoker", axis=1)
enc_BPMeds = pd.DataFrame(enc.fit_transform(X[["BPMeds"]]).toarray())
X = X.drop("BPMeds", axis=1)
enc_prevalentStroke = pd.DataFrame(enc.fit_transform(X[["prevalentStroke"]]).toarray())
X = X.drop("prevalentStroke", axis=1)
enc_prevalentHyp = pd.DataFrame(enc.fit_transform(X[["prevalentHyp"]]).toarray())
X = X.drop("prevalentHyp", axis=1)
enc_diabetes = pd.DataFrame(enc.fit_transform(X[["diabetes"]]).toarray())
X = X.drop("diabetes", axis=1)
X = X.join(enc_male, rsuffix="_male")
X = X.join(enc_education, rsuffix="_education")
X = X.join(enc_currentSmoker, rsuffix="_currentSmoker")
X = X.join(enc_BPMeds, rsuffix="_BPMeds")
X = X.join(enc_prevalentHyp, rsuffix="_prevalentHyp")
X = X.join(enc_prevalentStroke, rsuffix="_prevalentStroke")
X = X.join(enc_diabetes, rsuffix="_diabetes")
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.20, random_state = 0)
X_train_standard_scaler = pd.DataFrame.copy(X_train)
X_train_minMax = pd.DataFrame.copy(X_train)
X_train_maxAbs = pd.DataFrame.copy(X_train)
X_train_robust = pd.DataFrame.copy(X_train)
X_train_quantileNormal = pd.DataFrame.copy(X_train)
X_train_quantile_uniform = pd.DataFrame.copy(X_train)
X_train_power = pd.DataFrame.copy(X_train)
X_train_normalize = pd.DataFrame.copy(X_train)
X_test_standard_scaler = pd.DataFrame.copy(X_test)
X_test_minMax = pd.DataFrame.copy(X_test)
X_test_maxAbs = pd.DataFrame.copy(X_test)
X_test_robust = pd.DataFrame.copy(X_test)
X_test_quantileNormal = pd.DataFrame.copy(X_test)
X_test_quantile_uniform = pd.DataFrame.copy(X_test)
X_test_power = pd.DataFrame.copy(X_test)
X_test_normalize = pd.DataFrame.copy(X_test)
#######
####### STANDARD SCALER
#######
X_train_standard_scaler[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_standardScaler.fit_transform(X_train_standard_scaler[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
X_test_standard_scaler[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_standardScaler.fit_transform(X_test_standard_scaler[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
classifier_logistic_regression_standardScaler = LogisticRegression()
classifier_logistic_regression_standardScaler.fit(X_train_standard_scaler, Y_train)
print("model score Logistic Regression Standard scaler: %.3f" % classifier_logistic_regression_standardScaler.score(X_test_standard_scaler, Y_test))
classifier_SVC_standardScaler = SVC()
classifier_SVC_standardScaler.fit(X_train_standard_scaler, Y_train)
print("model score SVC Standard scaler: %.3f" % classifier_SVC_standardScaler.score(X_test_standard_scaler, Y_test))
classifier_DT_standardScaler = DecisionTreeClassifier()
classifier_DT_standardScaler.fit(X_train_standard_scaler, Y_train)
print("model score DT Standard scaler: %.3f" % classifier_DT_standardScaler.score(X_test_standard_scaler, Y_test))
classifier_RFC_standardScaler = RandomForestClassifier()
classifier_RFC_standardScaler.fit(X_train_standard_scaler, Y_train)
print("model score RF Standard scaler: %.3f" % classifier_RFC_standardScaler.score(X_test_standard_scaler, Y_test))
classifier_MLP_standardScaler = MLPClassifier()
classifier_MLP_standardScaler.fit(X_train_standard_scaler, Y_train)
print("model score MLP Standard scaler: %.3f" % classifier_MLP_standardScaler.score(X_test_standard_scaler, Y_test))
#######
####### MIN MAX SCALER
#######
X_train_minMax[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_MinMaxScaler.fit_transform(X_train_minMax[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
X_test_minMax[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_MinMaxScaler.fit_transform(X_test_minMax[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
classifier_logistic_regression_minMax = LogisticRegression()
classifier_logistic_regression_minMax.fit(X_train_minMax, Y_train)
print("model score Logistic Regression minMax Scaler: %.3f" % classifier_logistic_regression_minMax.score(X_test_minMax, Y_test))
classifier_SVC_minMax = SVC()
classifier_SVC_minMax.fit(X_train_minMax, Y_train)
print("model score SVC minMax Scaler: %.3f" % classifier_SVC_minMax.score(X_test_minMax, Y_test))
classifier_DT_minMax = DecisionTreeClassifier()
classifier_DT_minMax.fit(X_train_minMax, Y_train)
print("model score DT minMax Scaler: %.3f" % classifier_DT_minMax.score(X_test_minMax, Y_test))
classifier_RFC_minMax = RandomForestClassifier()
classifier_RFC_minMax.fit(X_train_minMax, Y_train)
print("model score RF minMax Scaler: %.3f" % classifier_RFC_minMax.score(X_test_minMax, Y_test))
classifier_MLP_minMax = MLPClassifier()
classifier_MLP_minMax.fit(X_train_minMax, Y_train)
print("model score MLP minMax Scaler: %.3f" % classifier_MLP_minMax.score(X_test_minMax, Y_test))
#######
####### MAX ABS SCALER
#######
X_train_maxAbs[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_MaxAbsScaler.fit_transform(X_train_maxAbs[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
X_test_maxAbs[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_MaxAbsScaler.fit_transform(X_test_maxAbs[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
classifier_logistic_regression_maxAbs = LogisticRegression()
classifier_logistic_regression_maxAbs.fit(X_train_maxAbs, Y_train)
print("model score Logistic Regression maxAbs Scaler: %.3f" % classifier_logistic_regression_maxAbs.score(X_test_maxAbs, Y_test))
classifier_SVC_maxAbs = SVC()
classifier_SVC_maxAbs.fit(X_train_maxAbs, Y_train)
print("model score SVC maxAbs Scaler: %.3f" % classifier_SVC_maxAbs.score(X_test_maxAbs, Y_test))
classifier_DT_maxAbs = DecisionTreeClassifier()
classifier_DT_maxAbs.fit(X_train_maxAbs, Y_train)
print("model score DT maxAbs Scaler: %.3f" % classifier_DT_maxAbs.score(X_test_maxAbs, Y_test))
classifier_RFC_maxAbs = RandomForestClassifier()
classifier_RFC_maxAbs.fit(X_train_maxAbs, Y_train)
print("model score RF maxAbs Scaler: %.3f" % classifier_RFC_maxAbs.score(X_test_maxAbs, Y_test))
classifier_MLP_maxAbs = MLPClassifier()
classifier_MLP_maxAbs.fit(X_train_maxAbs, Y_train)
print("model score MLP maxAbs Scaler: %.3f" % classifier_MLP_maxAbs.score(X_test_maxAbs, Y_test))
#######
####### ROBUST SCALER
#######
X_train_robust[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_RobustScaler.fit_transform(X_train_robust[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
X_test_robust[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_RobustScaler.fit_transform(X_test_robust[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
classifier_logistic_regression_robust = LogisticRegression()
classifier_logistic_regression_robust.fit(X_train_robust, Y_train)
print("model score Logistic Regression robust Scaler: %.3f" % classifier_logistic_regression_robust.score(X_test_robust, Y_test))
classifier_SVC_robust = SVC()
classifier_SVC_robust.fit(X_train_robust, Y_train)
print("model score SVC robust Scaler: %.3f" % classifier_SVC_robust.score(X_test_robust, Y_test))
classifier_DT_robust = DecisionTreeClassifier()
classifier_DT_robust.fit(X_train_robust, Y_train)
print("model score DT robust Scaler: %.3f" % classifier_DT_robust.score(X_test_robust, Y_test))
classifier_RFC_robust = RandomForestClassifier()
classifier_RFC_robust.fit(X_train_robust, Y_train)
print("model score RF robust Scaler: %.3f" % classifier_RFC_robust.score(X_test_robust, Y_test))
classifier_MLP_robust = MLPClassifier()
classifier_MLP_robust.fit(X_train_robust, Y_train)
print("model score MLP robust Scaler: %.3f" % classifier_MLP_robust.score(X_test_robust, Y_test))
#######
####### QUANTILE NORMAL SCALER
#######
X_train_quantileNormal[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_quantileTransformNormal.fit_transform(X_train_quantileNormal[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
X_test_quantileNormal[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_quantileTransformNormal.fit_transform(X_test_quantileNormal[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
classifier_logistic_regression_quantileNormal = LogisticRegression()
classifier_logistic_regression_quantileNormal.fit(X_train_quantileNormal, Y_train)
print("model score Logistic Regression quantile normal Scaler: %.3f" % classifier_logistic_regression_quantileNormal.score(X_test_quantileNormal, Y_test))
classifier_SVC_quantileNormal = SVC()
classifier_SVC_quantileNormal.fit(X_train_quantileNormal, Y_train)
print("model score SVC quantile normal Scaler: %.3f" % classifier_SVC_quantileNormal.score(X_test_quantileNormal, Y_test))
classifier_DT_quantileNormal = DecisionTreeClassifier()
classifier_DT_quantileNormal.fit(X_train_quantileNormal, Y_train)
print("model score DT quantile normal Scaler: %.3f" % classifier_DT_quantileNormal.score(X_test_quantileNormal, Y_test))
classifier_RFC_quantileNormal = RandomForestClassifier()
classifier_RFC_quantileNormal.fit(X_train_quantileNormal, Y_train)
print("model score RF quantile normal Scaler: %.3f" % classifier_RFC_quantileNormal.score(X_test_quantileNormal, Y_test))
classifier_MLP_quantileNormal = MLPClassifier()
classifier_MLP_quantileNormal.fit(X_train_quantileNormal, Y_train)
print("model score MLP quantile normal Scaler: %.3f" % classifier_MLP_quantileNormal.score(X_test_quantileNormal, Y_test))
#######
####### QUANTILE UNIFORM SCALER
#######
X_train_quantile_uniform[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_quantileTransform_Uniform.fit_transform(X_train_quantile_uniform[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
X_test_quantile_uniform[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_quantileTransform_Uniform.fit_transform(X_test_quantile_uniform[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
classifier_logistic_regression_quantileUniform = LogisticRegression()
classifier_logistic_regression_quantileUniform.fit(X_train_quantile_uniform, Y_train)
print("model score Logistic Regression quantile Uniform Scaler: %.3f" % classifier_logistic_regression_quantileUniform.score(X_test_quantile_uniform, Y_test))
classifier_SVC_quantileUniform = SVC()
classifier_SVC_quantileUniform.fit(X_train_quantile_uniform, Y_train)
print("model score SVC quantile Uniform Scaler: %.3f" % classifier_SVC_quantileUniform.score(X_test_quantile_uniform, Y_test))
classifier_DT_quantileUniform = DecisionTreeClassifier()
classifier_DT_quantileUniform.fit(X_train_quantile_uniform, Y_train)
print("model score DT quantile Uniform Scaler: %.3f" % classifier_DT_quantileUniform.score(X_test_quantile_uniform, Y_test))
classifier_RFC_quantileUniform = RandomForestClassifier()
classifier_RFC_quantileUniform.fit(X_train_quantile_uniform, Y_train)
print("model score RF quantile Uniform Scaler: %.3f" % classifier_RFC_quantileUniform.score(X_test_quantile_uniform, Y_test))
classifier_MLP_mquantileUniform= MLPClassifier()
classifier_MLP_mquantileUniform.fit(X_train_quantile_uniform, Y_train)
print("model score MLP quantile Uniform Scaler: %.3f" % classifier_MLP_mquantileUniform.score(X_test_quantile_uniform, Y_test))
#######
####### POWER SCALER
#######
X_train_power[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_Power.fit_transform(X_train_power[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
X_test_power[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_Power.fit_transform(X_test_power[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
classifier_logistic_regression_standPower= LogisticRegression()
classifier_logistic_regression_standPower.fit(X_train_power, Y_train)
print("model score Logistic Regression power Scaler: %.3f" % classifier_logistic_regression_standPower.score(X_test_power, Y_test))
classifier_SVC_standPower = SVC()
classifier_SVC_standPower.fit(X_train_power, Y_train)
print("model score SVC power Scaler: %.3f" % classifier_SVC_standPower.score(X_test_power, Y_test))
classifier_DT_standPower = DecisionTreeClassifier()
classifier_DT_standPower.fit(X_train_power, Y_train)
print("model score DT power Scaler: %.3f" % classifier_DT_standPower.score(X_test_power, Y_test))
classifier_RFC_standPower = RandomForestClassifier()
classifier_RFC_standPower.fit(X_train_power, Y_train)
print("model score RF power Scaler: %.3f" % classifier_RFC_standPower.score(X_test_power, Y_test))
classifier_MLP_standPower = MLPClassifier()
classifier_MLP_standPower.fit(X_train_power, Y_train)
print("model score MLP power Scaler: %.3f" % classifier_MLP_standPower.score(X_test_power, Y_test))
#######
####### NORMALIZE SCALER
#######
X_train_normalize[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_normalizer.fit_transform(X_train_normalize[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
X_test_normalize[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]] = stand_normalizer.fit_transform(X_test_normalize[["age", "cigsPerDay", "totChol", "sysBP", "diaBP", "BMI", "heartRate", "glucose"]])
classifier_logistic_regression_normalize= LogisticRegression()
classifier_logistic_regression_normalize.fit(X_train_normalize, Y_train)
print("model score Logistic Regression normalize Scaler: %.3f" % classifier_logistic_regression_normalize.score(X_test_normalize, Y_test))
classifier_SVC_normalize = SVC()
classifier_SVC_normalize.fit(X_train_normalize, Y_train)
print("model score SVC normalize Scaler: %.3f" % classifier_SVC_normalize.score(X_test_normalize, Y_test))
classifier_DT_normalize = DecisionTreeClassifier()
classifier_DT_normalize.fit(X_train_normalize, Y_train)
print("model score DT normalize Scaler: %.3f" % classifier_DT_normalize.score(X_test_normalize, Y_test))
classifier_RFC_normalize = RandomForestClassifier()
classifier_RFC_normalize.fit(X_train_normalize, Y_train)
print("model score RF normalize Scaler: %.3f" % classifier_RFC_normalize.score(X_test_normalize, Y_test))
classifier_MLP_normalize = MLPClassifier()
classifier_MLP_normalize.fit(X_train_normalize, Y_train)
print("model score MLP normalize Scaler: %.3f" % classifier_MLP_normalize.score(X_test_normalize, Y_test))
#LOGISTIC REGRESSION#
print("#LOGISTIC REGRESSION#")
print("_____________________")
print("model score Logistic Regression Standard scaler: %.3f" % classifier_logistic_regression_standardScaler.score(X_test_standard_scaler, Y_test))
print("model score Logistic Regression minMax Scaler: %.3f" % classifier_logistic_regression_minMax.score(X_test_minMax, Y_test))
print("model score Logistic Regression maxAbs Scaler: %.3f" % classifier_logistic_regression_maxAbs.score(X_test_maxAbs, Y_test))
print("model score Logistic Regression robust Scaler: %.3f" % classifier_logistic_regression_robust.score(X_test_robust, Y_test))
print("model score Logistic Regression quantile normal Scaler: %.3f" % classifier_logistic_regression_quantileNormal.score(X_test_quantileNormal, Y_test))
print("model score Logistic Regression quantile Uniform Scaler: %.3f" % classifier_logistic_regression_quantileUniform.score(X_test_quantile_uniform, Y_test))
print("model score Logistic Regression power Scaler: %.3f" % classifier_logistic_regression_standPower.score(X_test_power, Y_test))
print("model score Logistic Regression normalize Scaler: %.3f" % classifier_logistic_regression_normalize.score(X_test_normalize, Y_test))
#SVC#
print("#SVC#")
print("_____________________")
print("model score SVC Standard scaler: %.3f" % classifier_SVC_standardScaler.score(X_test_standard_scaler, Y_test))
print("model score SVC minMax Scaler: %.3f" % classifier_SVC_minMax.score(X_test_minMax, Y_test))
print("model score SVC maxAbs Scaler: %.3f" % classifier_SVC_maxAbs.score(X_test_maxAbs, Y_test))
print("model score SVC robust Scaler: %.3f" % classifier_SVC_robust.score(X_test_robust, Y_test))
print("model score SVC quantile normal Scaler: %.3f" % classifier_SVC_quantileNormal.score(X_test_quantileNormal, Y_test))
print("model score SVC quantile Uniform Scaler: %.3f" % classifier_SVC_quantileUniform.score(X_test_quantile_uniform, Y_test))
print("model score SVC power Scaler: %.3f" % classifier_SVC_standPower.score(X_test_power, Y_test))
print("model score SVC normalize Scaler: %.3f" % classifier_SVC_normalize.score(X_test_normalize, Y_test))
print("_____________________")
print("_____________________")
#DT#
print("#DT#")
print("_____________________")
print("model score DT Standard scaler: %.3f" % classifier_DT_standardScaler.score(X_test_standard_scaler, Y_test))
print("model score DT minMax Scaler: %.3f" % classifier_DT_minMax.score(X_test_minMax, Y_test))
print("model score DT maxAbs Scaler: %.3f" % classifier_DT_maxAbs.score(X_test_maxAbs, Y_test))
print("model score DT robust Scaler: %.3f" % classifier_DT_robust.score(X_test_robust, Y_test))
print("model score DT quantile normal Scaler: %.3f" % classifier_DT_quantileNormal.score(X_test_quantileNormal, Y_test))
print("model score DT quantile Uniform Scaler: %.3f" % classifier_DT_quantileUniform.score(X_test_quantile_uniform, Y_test))
print("model score DT power Scaler: %.3f" % classifier_DT_standPower.score(X_test_power, Y_test))
print("model score DT normalize Scaler: %.3f" % classifier_DT_normalize.score(X_test_normalize, Y_test))
print("_____________________")
print("_____________________")
#RF#
print("#RF#")
print("_____________________")
print("model score RF Standard scaler: %.3f" % classifier_RFC_standardScaler.score(X_test_standard_scaler, Y_test))
print("model score RF minMax Scaler: %.3f" % classifier_RFC_minMax.score(X_test_minMax, Y_test))
print("model score RF maxAbs Scaler: %.3f" % classifier_RFC_maxAbs.score(X_test_maxAbs, Y_test))
print("model score RF robust Scaler: %.3f" % classifier_RFC_robust.score(X_test_robust, Y_test))
print("model score RF quantile normal Scaler: %.3f" % classifier_RFC_quantileNormal.score(X_test_quantileNormal, Y_test))
print("model score RF quantile Uniform Scaler: %.3f" % classifier_RFC_quantileUniform.score(X_test_quantile_uniform, Y_test))
print("model score RF power Scaler: %.3f" % classifier_RFC_standPower.score(X_test_power, Y_test))
print("model score RF normalize Scaler: %.3f" % classifier_RFC_normalize.score(X_test_normalize, Y_test))
print("_____________________")
print("_____________________")
#MLP#
print("#MLP#")
print("_____________________")
print("model score MLP Standard scaler: %.3f" % classifier_MLP_standardScaler.score(X_test_standard_scaler, Y_test))
print("model score MLP minMax Scaler: %.3f" % classifier_MLP_minMax.score(X_test_minMax, Y_test))
print("model score MLP maxAbs Scaler: %.3f" % classifier_MLP_maxAbs.score(X_test_maxAbs, Y_test))
print("model score MLP robust Scaler: %.3f" % classifier_MLP_robust.score(X_test_robust, Y_test))
print("model score MLP quantile normal Scaler: %.3f" % classifier_MLP_quantileNormal.score(X_test_quantileNormal, Y_test))
print("model score MLP quantile Uniform Scaler: %.3f" % classifier_MLP_mquantileUniform.score(X_test_quantile_uniform, Y_test))
print("model score MLP power Scaler: %.3f" % classifier_MLP_standPower.score(X_test_power, Y_test))
print("model score MLP normalize Scaler: %.3f" % classifier_MLP_normalize.score(X_test_normalize, Y_test))
print("_____________________")
print("_____________________")
import tensorflow as tf
print (("Tensorflow version: {0}").format(tf.__version__))
tensor_classifier = tf.keras.models.Sequential()
#layer
tensor_classifier.add(tf.keras.layers.Dense(50, activation="relu", input_dim = X_train_power.shape[1]))
tensor_classifier.add(tf.keras.layers.Dense(units=1, activation="sigmoid"))
#compile tensorflow
tensor_classifier.compile(optimizer="adam",
loss = tf.losses.binary_crossentropy,
metrics =["accuracy"])
model_summary = tensor_classifier.summary()
model_config = tensor_classifier.get_config()
#train tensorflow
history = tensor_classifier.fit(X_train_power, Y_train, epochs=50, batch_size=32)
#train tensorflow evaluation
print("evalutate on train data")
y_train_predicted_tensor = tensor_classifier.predict(X_train_power)
y_train_predicted_tensor_approx = (np.rint(y_train_predicted_tensor))
cm = confusion_matrix(y_train_predicted_tensor_approx, Y_train)
print(cm)
results = tensor_classifier.evaluate(X_train_power, Y_train, batch_size = 128)
print("test loss, test acc:", results)
#test tensorflow evaluation
print("evalutate on test data")
y_test_tensor = tensor_classifier.predict(X_test_power)
y_test_predicted_tensor_approx = (np.rint(y_test_tensor))
cm = confusion_matrix(y_test_predicted_tensor_approx, Y_test)
print(cm)
results = tensor_classifier.evaluate(X_test_power, Y_test, batch_size = 128)
print("test loss, test acc:", results)