Issue
The KNeighborsClassifier from sklearn predicts the class calculating the k instances that have the least distance, right? But, can we return the instances that he is using to do this prediction?
for instance: if knn calculate that Ana should be a woman due the distance from Mary and Alexa, can we return ['Mary','Alexa']
Solution
There is the method kneighbors, that returns indices of and distances to the neighbors of each point.
First, you need to fit the algorithm on the training dataset, then you can ask to give k neighbors
for some specific items.
Answered By - Danylo Baibak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.