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

Pedro Pazzini pedropazzini at gmail.com
Tue Jan 3 10:33:22 EST 2017


Joel,

Your explanation helped me understand it.

Thanks!


2017-01-02 19:10 GMT-02:00 Joel Nothman <joel.nothman at gmail.com>:

> n_indexed means the number of samples in the X passed to fit. It needs to
> be able to compare each prediction sample with each training sample.
>
> On 3 January 2017 at 07:44, Pedro Pazzini <pedropazzini at gmail.com> wrote:
>
>> 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.KNeigh
>> borsClassifier.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
>>
>> _______________________________________________
>> scikit-learn mailing list
>> scikit-learn at python.org
>> https://mail.python.org/mailman/listinfo/scikit-learn
>>
>>
>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20170103/67cb7cd6/attachment.html>


More information about the scikit-learn mailing list