程序如下:
data <- read.csv("E://jue//logistic.csv",header=T)
ind <- sample(2, nrow(data), replace=TRUE, prob=c(0.8, 0.2))
traindata <- data[ind==1,]
testdata<- data[ind==2,]
library(MASS)
library(klaR)
res<-naiveBayes(id~a+b+c+d+e+f+g+h+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z+aa+ab+ac+ad+ae+af+ag+ah+ai+aj+ak+al+am+an+ao+ap+aq+ar+as,
traindata)
pre<-predict(res,testdata)
table(pre,testdata$id)
write.csv(pre,"E://predictdata16.csv")