-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWinePredictor.py
109 lines (45 loc) · 1.2 KB
/
WinePredictor.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
#!/usr/bin/env python
# coding: utf-8
# In[2]:
import pandas as pd
from sklearn import datasets
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
# In[3]:
wine=datasets.load_wine()
# In[4]:
print(wine.feature_names)
# In[5]:
print(wine.target_names)
# In[6]:
print(wine.data[0:5])
# In[7]:
print(wine.target)
# In[8]:
X_train,X_test,y_train,y_test=train_test_split(wine.data,wine.target,test_size=0.3)
# In[9]:
knn=KNeighborsClassifier(n_neighbors=1)
model=knn.fit(X_train,y_train)
result=model.predict(X_test)
Percentage=accuracy_score(result,y_test)
print("Accuracy is ",Percentage*100)
# In[17]:
from sklearn import tree
clf=tree.DecisionTreeClassifier()
model=clf.fit(X_train,y_train)
result=model.predict(X_test)
Percentage=accuracy_score(result,y_test)
print("Accuracy is",Percentage*100)
# In[12]:
from sklearn.linear_model import LogisticRegression
# In[16]:
clf=LogisticRegression()
model=clf.fit(X_train,y_train)
result=model.predict(X_test)
Percentage=accuracy_score(result,y_test)
print("Accuracy is :",Percentage*100)
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]: