forked from lazyprogrammer/machine_learning_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathknn_donut.py
More file actions
23 lines (18 loc) · 657 Bytes
/
knn_donut.py
File metadata and controls
23 lines (18 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# https://deeplearningcourses.com/c/data-science-supervised-machine-learning-in-python
# https://www.udemy.com/data-science-supervised-machine-learning-in-python
from __future__ import print_function, division
from builtins import range, input
# Note: you may need to update your version of future
# sudo pip install -U future
from knn import KNN
from util import get_donut
import matplotlib.pyplot as plt
if __name__ == '__main__':
X, Y = get_donut()
# display the data
plt.scatter(X[:,0], X[:,1], s=100, c=Y, alpha=0.5)
plt.show()
# get the accuracy
model = KNN(3)
model.fit(X, Y)
print("Accuracy:", model.score(X, Y))