我naiveBayes e1071
用于对我的数据集进行分类(分类类别:“V32”0/1)。
这是我所做的:
d <- read.table("Modeling_Data.txt",header=FALSE,sep="\t",
comment.char="",quote="")
#divide into training and test data 70:30
trainingIndex <- createDataPartition(d$V32, p=.7, list=F)
d.training <- d[trainingIndex,]
d.testing <- d[-trainingIndex,]
nb.classifier <- naiveBayes(as.factor(d$V32) ~ ., data = d.training)
但我得到这个错误:
Error in names(dimnames(tables[[i]])) <- c(Yname, colnames(x)[i]) :
attempt to set an attribute on NULL
predict(nb.classifier,d.testing[,-50000])
Error in predict(nb.classifier, d.testing[, -50000]) :
object 'nb.classifier' not found
我尝试使用包含的数据集(虹膜),一切正常。我的方法有什么问题?