Re: Questions about knn~

作者: mercurial (多變)   2005-03-26 15:40:17
I also try to write my own knn function.
But when I try to calculate the Eucledean distance of
the 4/5*520000 training data and 1/5*520000 testing data.
I can't even create a 416000*104000 matrix to put all the distances.
R said: too many elements specified. ><"
※ 引述《untitled (Causality)》之銘言:
: Yes :)
: ※ 引述《Tonnny (^~^)》之銘言:
: : I try to write the knn function by myself instead of using the package.
: : Thus some detailed about knn should be verified first.
: : testing set:
: : 5 7 3
: : training set:
: : Label C1 C2 C3
: : A 4 8 9 sqrt( (5-4)^2 + (7-8)^2 + (3-9)^2 ) = sqrt(38)
: : B 2 6 5 sqrt( (5-2)^2 + (7-6)^2 + (3-5)^2 ) = sqrt(14)
: : A 6 1 7 sqrt( (5-6)^2 + (7-1)^2 + (3-7)^2 ) = sqrt(53)
: : B 2 3 5 sqrt( (5-2)^2 + (7-3)^2 + (3-5)^2 ) = sqrt(29)
: : Therefore, the 1-nearest neighbor is "B".
: : the 3-nearest neighbor is "B". (B:14,29: vote=2 A:38: vote=1)
: : Is this procedure correct?
: : Thanks for answering~

Links booklink

Contact Us: admin [ a t ] ucptt.com