[R] knn class probabilities

Max Kuhn mxkuhn at gmail.com
Wed Oct 1 20:04:01 CEST 2008

On Tue, Sep 30, 2008 at 8:06 PM, Mike Fugate <fugate at lanl.gov> wrote:
> Good Day,
> I'm using the knn function in the package class.  With k set to 3, the
> function returns proportions of 1/3, 0.5, 0.6, 2/3, 3/4, and 1.0 for the
> test cases.  I don't understand how with k set to 3 the proportions can be
> anything other than 1/3, 2/3, or 1.0  I've seen similar inconsistencies with
> k set to 5.


First, you should probably contact the package first about questions
related to a specific package.

Second, please read the documentation for the function (via ?knn at
the command line). There you would see an argument called use.all with
description "controls handling of ties. If true, all distances equal
to the kth largest are included. If false, a random selection of
distances equal to the kth is chosen to use exactly k neighbours."



More information about the R-help mailing list