[scikit-learn] KNeighborsClassifier and metric='precomputed'

Pedro Pazzini pedropazzini at gmail.com
Mon Jan 2 15:44:25 EST 2017


Hi all!

I'm trying to use a KNeighborsClassifier with precomputed metric. In it's
predict method (http://scikit-learn.org/stable/modules/generated/sklearn
.neighbors.KNeighborsClassifier.html#sklearn.neighbors.KNeighborsClassifier.predict)
it says the input should be:

"(n_query, n_indexed) if metric == ‘precomputed’"

What is n_indexed?

Shouldn't the shape of the input in the predict method be (n_query,n_query)?

How can I use the predict method after fitting the classifier with a
distance matrix?

Regards,
Pedro Pazzini
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20170102/9be7c546/attachment.html>


More information about the scikit-learn mailing list