I was trying to implement KNN for handwritten character recognition where I found out that the execution of code was taking a lot of time. When added parameter leaf_size with value 400, I observed that time taken by code to execute was significantly reduced.
Original Code:
knn = KNeighborsClassifier(n_neighbors=3)
New Code:
knn = KNeighborsClassifier(n_neighbors=3,leaf_size=400)
I have read few documentation and articles regarding the leaf_size parameter of the KDtree/Balltree but couldn't find any good enough reference on how to safely tune this parameter without any accuracy and information loss.
It would be very kind if someone could share some insights regarding the above issue.
Related Articles I referred to:
1.) http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KDTree.html
2.) https://jakevdp.github.io/blog/2013/04/29/benchmarking-nearest-neighbor-searches-in-python/
3.) http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html
leafsize
? – Johnathanjohnathon