I have used knn to classify my dataset. But I do not know how to measure the accuracy of the trained classifier. Does scikit have any inbuilt function to check accuracy of knn classifier?
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier()
knn.fit(training, train_label)
predicted = knn.predict(testing)
Appreciate all the help. Thanks
Use sklearn.metrics.accuracy_score
:
acc = accuracy_score(test_label, predicted)