text_plain_output_1.png
from sklearn.neighbors import KNeighborsClassifier

clf = KNeighborsClassifier()
clf.fit(X_train, y_train)
clf.score(X_test, y_test)

clf = KNeighborsClassifier(2)
clf.fit(X_train, y_train)
clf.score(X_test, y_test)

clf = KNeighborsClassifier()
clf.fit(X_train, y_train)
clf.score(X_test, y_test)

scores = []
for k in range(1, 11):
    clf = KNeighborsClassifier(k)
    clf.fit(X_train, y_train)
    score = clf.score(X_test, y_test)
    scores.append(score)

clf = KNeighborsClassifier(metric='manhattan')
clf.fit(X_train, y_train)
clf.score(X_test, y_test)