[ top | up ]

k-Nearest Neighbour Classification

Usage

knn(train, test, class, k=1, l=1, prob=F, use.all=T)

Arguments

train matrix or data frame of training set cases.
test matrix or data frame of test set cases. A vector will be interpreted as a row vector for a single case.
class factor of true classifications of training set
k number of neighbours considered.
l minimum vote for definite decision, otherwise doubt. (More precisely, less than k-l dissenting votes are allowed, even if k is increased by ties.)
prob If this is true, the proportion of the votes for the winning class are returned as attribute prob.
use.all 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.

Value

factor of classifications of test set. doubt will be returned as NA.

See Also

knn1, knn.cv