text_plain_output_1.png
from sklearn.metrics import accuracy_score,precision_score,confusion_matrix,f1_score,classification_report

from sklearn.neighbors import KNeighborsClassifier

from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors=5)
knn.fit(X_train, y_train)
print('The accuracy of the Knn classifier on training data is {:.2f}'.format(knn.score(X_train, y_train)))
print('The accuracy of the Knn classifier on test data is {:.2f}'.format(knn.score(X_test, y_test)))
knnpre = knn.predict(X_test)
cm = confusion_matrix(y_test, knnpre)
print(cm)