-
Notifications
You must be signed in to change notification settings - Fork 0
/
models_cofig.py
124 lines (108 loc) · 3.57 KB
/
models_cofig.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
from sklearn import impute
from imblearn.pipeline import Pipeline as imb_pipeline
from imblearn.ensemble import BalancedRandomForestClassifier, RUSBoostClassifier
from imblearn.under_sampling import RandomUnderSampler
from imblearn.combine import SMOTETomek
from imblearn.over_sampling import SMOTE
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import VotingClassifier, RandomForestClassifier
from xgboost import XGBClassifier
# This file holds all the base models that are used in the benchmark
models = {}
models["Decision Tree"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("estimator", DecisionTreeClassifier(random_state=42)),
]
)
models["Random Forest"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("estimator", RandomForestClassifier(random_state=42)),
]
)
models["XGBoost"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("estimator", XGBClassifier(random_state=42)),
]
)
models["XGBoost SMOTE"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("resampling", SMOTE(random_state=42)),
("estimator", XGBClassifier(random_state=42)),
]
)
models["XGBoost SMOTETomek"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("resampling", SMOTETomek(random_state=42)),
("estimator", XGBClassifier(random_state=42)),
]
)
models["XGBoost RandomUnderSampler"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("resampling", RandomUnderSampler(random_state=42)),
("estimator", XGBClassifier(random_state=42)),
]
)
models["Random Forest SMOTE"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
('resampling', SMOTE(random_state=42)),
("estimator", RandomForestClassifier(random_state=42)),
]
)
models["XGBoost Weighted"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("estimator", XGBClassifier(scale_pos_weight=99, random_state=42)),
]
)
models["Random Forest Weighted"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("estimator", RandomForestClassifier(
class_weight='balanced', random_state=42)),
]
)
models["RUSBoost"] = imb_pipeline(
steps=[
('imputer', impute.SimpleImputer(strategy='median')),
('rusboost', RUSBoostClassifier(random_state=42))
]
)
models["Balanced Random Forest"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("estimator", BalancedRandomForestClassifier(random_state=42)),
]
)
models["Balanced Random Forest KNNImputer"] = imb_pipeline(
steps=[
("imputer", impute.KNNImputer(n_neighbors=5)),
("estimator", BalancedRandomForestClassifier(random_state=42)),
]
)
models["XGBoost RandomUnderSampler KNNImputer"] = imb_pipeline(
steps=[
("imputer", impute.KNNImputer(n_neighbors=5)),
("resampling", RandomUnderSampler(random_state=42)),
("estimator", XGBClassifier(random_state=42)),
]
)
models["Voting Classifier"] = imb_pipeline(
steps=[
("imputer", impute.SimpleImputer()),
("estimator", VotingClassifier(estimators=[
('brf', models["Balanced Random Forest"]),
('xgb', models["XGBoost RandomUnderSampler"]),
],
voting='soft',)),
]
)
scores_dict = {}
for model in models:
scores_dict[model] = []