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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to