text_plain_output_1.png
from sklearn.neighbors import KNeighborsClassifier

import sklearn.metrics as pm

knn_model = KNeighborsClassifier(n_neighbors=7)
knn_model.fit(X_train, y_train)
y_pred = knn_model.predict(X_test)

import sklearn.metrics as pm
pm.confusion_matrix(y_test, y_pred)

tn, fp, fn, tp = pm.confusion_matrix(y_test, y_pred).ravel()

predictions = knn_model.predict(X_train)
print('Performance measures over training data set:')
print(' - precision is ', pm.precision_score(y_train, predictions))
print(' - recall is ', pm.recall_score(y_train, predictions))
print(' - f-measure is', pm.f1_score(y_train, predictions))