I work with Scikit-Learn's nearest neighbors/radius classification with a precomputed metric. That means, I pass a n_samples_train x n_samples_train matrix of pairwise distances to the classifier's fit-method.
Now I wonder why this has to be done. Learning with knn simply should mean "store the samples", but the computation of the distances should only take place later on, during generalization (during that step, I of course calculate a distance matrix between my training samples and my test samples, so a matrix of size n_samples_train x n_samples_test).
In the case of SVM, for example, I pass a precomputed matrix (the Gramian, a similarity matrix) to the fit method of the smv.SVC-object. Then the optimization stuff takes place, the support vectors are found and so on. There, that matrix is absolutely necessary during training.
But I can see no reason why there is the need for a precomputed matrix with fitting in neighbors/radius classification.
Can someone give me a relevant hint, please?
I'd love to skip the calculation of a training matrix for knn with scikit learn.
Best greetings and thank you. :-)