0
我用naiveBayes e1071
來分類我的數據集(Classification class:「V32」0/1)。naive bayes分類錯誤r
這裏是我做的:
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
我試圖用附帶的數據集(IRIS),一切工作正常。我的方法有什麼問題?