-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscores.py
38 lines (26 loc) · 942 Bytes
/
scores.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
import pandas as pd
from sklearn import tree
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.neural_network import MLPClassifier
diabetes_db = pd.read_csv("diabetes_complete.csv")
X = diabetes_db.drop("Outcome", axis=1)
y = diagnostic = diabetes_db["Outcome"]
X_train, X_test, y_train, y_test = train_test_split(
X, y, stratify=y, random_state=1
)
def score_for_decision_tree():
clf = tree.DecisionTreeClassifier()
clf.fit(X_train, y_train)
score = clf.score(X_test, y_test)
return score
def score_for_knn():
neigh = KNeighborsClassifier(n_neighbors=2)
neigh.fit(X_train, y_train)
score = neigh.score(X_test, y_test)
return score
def score_for_neural_network():
clf = MLPClassifier(activation="logistic", random_state=1, max_iter=3000)
clf.fit(X_train, y_train)
score = clf.score(X_test, y_test)
return score