RE: [R] Interpreting knn Results

2004-03-29 Thread Liaw, Andy
Maybe you should show your colleague how to access help pages in R?  Right
in ?knn, it says:

prob: If this is true, the proportion of the votes for the winning
  class are returned as attribute 'prob'. 

so 1.0 mean all three NNs are of the `winning'; i.e., predicted, class, and
0.7 means 2 out of the 3 NNs are of the winning class, etc.  

Andy

 From: Ko-Kang Kevin Wang
 
 Hi,
 
 [I'm posting this on behalf of a colleague -- as I don't know 
 knn myself...]
 
 How to interpret the knn() results?
 
 Tried the example codes in the documentation:
  data(iris3)
  train - rbind(iris3[1:25,,1], iris3[1:25,,2], iris3[1:25,,3])
  test - rbind(iris3[26:50,,1], iris3[26:50,,2], iris3[26:50,,3])
  cl - factor(c(rep(s,25), rep(c,25), rep(v,25)))
  knn(train, test, cl, k = 3, prob=TRUE)
  attributes(.Last.value)
 and got:
 $levels
 [1] c s v
 
 $class
 [1] factor
 
 $prob
  [1] 1.000 1.000 1.000 1.000 1.000 1.000
  [7] 1.000 1.000 1.000 1.000 1.000 1.000
 [13] 1.000 1.000 1.000 1.000 1.000 1.000
 [19] 1.000 1.000 1.000 1.000 1.000 1.000
 [25] 1.000 1.000 1.000 0.667 1.000 1.000
 [31] 1.000 1.000 1.000 0.667 1.000 1.000
 [37] 1.000 1.000 1.000 1.000 1.000 1.000
 [43] 1.000 1.000 1.000 1.000 1.000 1.000
 [49] 1.000 1.000 1.000 0.667 0.750 1.000
 [55] 1.000 1.000 1.000 1.000 0.500 1.000
 [61] 1.000 1.000 1.000 0.667 1.000 1.000
 [67] 1.000 1.000 1.000 1.000 1.000 0.667
 [73] 1.000 1.000 0.667
 
 
 What do the prob mean?
 
 Thanks,
 
 Kevin
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Interpreting knn Results

2004-03-29 Thread Ko-Kang Kevin Wang
Hi,

 -Original Message-
 From: Liaw, Andy [mailto:[EMAIL PROTECTED]
 Maybe you should show your colleague how to access help pages
 in R?  Right
 in ?knn, it says:

 prob: If this is true, the proportion of the votes for the
winning
   class are returned as attribute 'prob'.

 so 1.0 mean all three NNs are of the `winning'; i.e.,
 predicted, class, and
 0.7 means 2 out of the 3 NNs are of the winning class, etc.

Whoops sorry, I guess I should've known that *_*.  She lost access to
her email due to a technical problem and I was running to a tutorial
so didn't have time to think.  After my tutorial I looked at the
results with her and figured it out*_*

Thanks,

Kevin

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Interpreting knn Results

2004-03-28 Thread Ko-Kang Kevin Wang
Hi,

[I'm posting this on behalf of a colleague -- as I don't know knn myself...]

How to interpret the knn() results?

Tried the example codes in the documentation:
 data(iris3)
 train - rbind(iris3[1:25,,1], iris3[1:25,,2], iris3[1:25,,3])
 test - rbind(iris3[26:50,,1], iris3[26:50,,2], iris3[26:50,,3])
 cl - factor(c(rep(s,25), rep(c,25), rep(v,25)))
 knn(train, test, cl, k = 3, prob=TRUE)
 attributes(.Last.value)
and got:
$levels
[1] c s v

$class
[1] factor

$prob
 [1] 1.000 1.000 1.000 1.000 1.000 1.000
 [7] 1.000 1.000 1.000 1.000 1.000 1.000
[13] 1.000 1.000 1.000 1.000 1.000 1.000
[19] 1.000 1.000 1.000 1.000 1.000 1.000
[25] 1.000 1.000 1.000 0.667 1.000 1.000
[31] 1.000 1.000 1.000 0.667 1.000 1.000
[37] 1.000 1.000 1.000 1.000 1.000 1.000
[43] 1.000 1.000 1.000 1.000 1.000 1.000
[49] 1.000 1.000 1.000 0.667 0.750 1.000
[55] 1.000 1.000 1.000 1.000 0.500 1.000
[61] 1.000 1.000 1.000 0.667 1.000 1.000
[67] 1.000 1.000 1.000 1.000 1.000 0.667
[73] 1.000 1.000 0.667


What do the prob mean?

Thanks,

Kevin

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html