Created
May 20, 2019 04:42
-
-
Save ahmdrz/5d92ee95cf12c697e72b269c7f6f7b66 to your computer and use it in GitHub Desktop.
Simple knn in sklearn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.neighbors import KNeighborsClassifier | |
samples = [[0], [1], [2], [3]] | |
labels = [0, 0, 1, 1] | |
item_to_predict = [[1.1]] | |
model = KNeighborsClassifier(n_neighbors=3, metric='euclidean') | |
model.fit(samples, labels) | |
predict = model.predict(item_to_predict) | |
print(predict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment