[R] knncat question

Kuhn, Max Max.Kuhn at pfizer.com
Mon Mar 12 16:09:17 CET 2007


Aimin,

I haven't used that function and you haven't old us anything about your
data or the system that you are on, but here is a guess: when the number
of votes are tied, a random choice is usually made between the classes.
0.63 and 0.67 are relatively close and this might account for the
difference.

If you have C classes, try using k such that C %% k > 0 to prevent ties.
You may get the same answer.

Max
 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Aimin Yan
Sent: Sunday, March 11, 2007 11:03 PM
To: r-help at stat.math.ethz.ch
Subject: [R] knncat question

I use knncat to make a predictive model
and get misclass rate
 > knncat.m<-knncat(training.new,k=c(10,20),classcol=5)
 > knncat.m
Training set misclass rate: 36.88%

then I try to calculate prediction accuracy by the following:

 > pr.knncat.train <- predict 
(knncat.m,training.new,training.new,train.classcol=5,newdata.classcol=5)
 > tb.knncat.train <-table (pr.knncat.train, training.new$y)
 >
nnb.accuracy.train<-round(sum(diag(tb.knncat.train))/sum(tb.knncat.train
),2)
 > cat("NNB prediction accuracy for training",nnb.accuracy.train,"\n")
NNB prediction accuracy for training 0.67

I thought I should to get :
100%-36.88%=63.12%=0.63.

But in my calculation, I get 0.67.
Is my calculation wrong?

thanks,

Aimin

______________________________________________
R-help at stat.math.ethz.ch 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.

----------------------------------------------------------------------
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}



More information about the R-help mailing list