[R] knncat question
Aimin Yan
aiminy at iastate.edu
Mon Mar 12 04:02:46 CET 2007
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
More information about the R-help
mailing list