[R] question about knn
Rami.Albatal at imag.fr
Rami.Albatal at imag.fr
Mon Aug 11 09:19:33 CEST 2008
Hello all,
am a newby in R,
am trying the knn function, and am doing just a stupid test :
> knn(c(1,2,3,4,5,6), c(3), k=4 ,prob=TRUE,factor(c(1:6)))
the result is unstable !! i have each time different result :
[1] 5
attr(,"prob")
[1] 0.1666667
Levels: 1 2 3 4 5 6
[1] 4
attr(,"prob")
[1] 0.1666667
Levels: 1 2 3 4 5 6
[1] 1
attr(,"prob")
[1] 0.1666667
Levels: 1 2 3 4 5 6
ect...
I would like to know why ?
the thing that am searching for is to have the 4 NN and sort them
according to there distance to the test point.
Tank you
Rami
More information about the R-help
mailing list