-
Notifications
You must be signed in to change notification settings - Fork 2
/
algorithms.py
62 lines (61 loc) · 2.09 KB
/
algorithms.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
from sklearn.model_selection import GridSearchCV
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis, QuadraticDiscriminantAnalysis
from sklearn.neighbors import KNeighborsClassifier
# Defining all algorithms and their grids for hyper-parameter tuning
classifiers = [
(
'Logistic Regression',
GridSearchCV(
LogisticRegression(random_state=2018),
{
'penalty': ['l1', 'l2'],
'C': [10**i for i in range(-5, 3)]
}, scoring='roc_auc')
), (
'Decision Tree',
GridSearchCV(
DecisionTreeClassifier(random_state=2018),
{
'criterion': ['entropy', 'gini'],
'max_depth': [None, 3, 5, 10, 15],
'max_features': [None, 'auto'],
'min_samples_split': [2, 5, 10],
}, scoring='roc_auc')
), (
'Linear Discriminant Analysis',
LinearDiscriminantAnalysis()
), (
'Quadratic Discriminant Analysis',
QuadraticDiscriminantAnalysis()
), (
'K-Nearest Neighbors',
GridSearchCV(
KNeighborsClassifier(),
{
'n_neighbors': [3, 5, 7, 11, 15, 21],
'metric': ['minkowski', 'manhattan'],
}, scoring='roc_auc'),
), (
'Random Forest',
GridSearchCV(
RandomForestClassifier(random_state=2018),
{
'criterion': ['entropy', 'gini'],
'max_depth': [None, 3, 5, 10, 15],
'max_features': [None, 'auto'],
'n_estimators': [10, 100, 500],
}, scoring='roc_auc'),
), (
'Support Vector Machine',
GridSearchCV(
SVC(probability=True, random_state=2018),
{
'kernel': ['linear', 'rbf'],
'C': [10**i for i in range(-5, 3)]
}, scoring='roc_auc')
)
]