-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithms.py
More file actions
48 lines (27 loc) · 1.21 KB
/
algorithms.py
File metadata and controls
48 lines (27 loc) · 1.21 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
from sklearn.pipeline import Pipeline
#Five different algorithms all using piplines
def gaussNB(scaler,skb):
from sklearn.naive_bayes import GaussianNB
gnb = GaussianNB()
clf = Pipeline(steps=[('Scaler',scaler), ('SKB', skb), ('NaiveBayes', gnb)])
return clf
def DTree(scaler,skb):
from sklearn import tree
dt = tree.DecisionTreeClassifier(random_state=42,min_samples_split=5,splitter='random')
clf = Pipeline(steps=[('Scaler',scaler), ('SKB', skb), ('Decision Tree', dt)])
return clf
def LogReg(scaler,skb):
from sklearn.linear_model import LogisticRegression
lg = LogisticRegression(class_weight='balanced')
clf = Pipeline(steps=[('Scaler',scaler), ('SKB', skb), ('Logistic Regression', lg)])
return clf
def LinearS(scaler,skb):
from sklearn.svm import LinearSVC
lsvc = LinearSVC(C=10,class_weight='balanced')
clf = Pipeline(steps=[('Scaler',scaler), ('SKB', skb), ('Linear SVC', lsvc)])
return clf
def RandForest(scaler,skb):
from sklearn.ensemble import RandomForestClassifier
rf = RandomForestClassifier(n_estimators=100,bootstrap=False)
clf = Pipeline(steps=[('Scaler',scaler), ('SKB', skb), ('Random Forest', rf)])
return clf