Skip to content
Prev 179510 / 398503 Next

How to do Naive Bayes in R?

On Wednesday 06 May 2009, Tim LIU wrote:
# start here:
help.search('bayes')

# in which you will find:
e1071::naiveBayes

# which means:
library(e1071)
?naiveBayes

# and compared to your example:
cl <- kmeans(iris[,1:4], 3)
table(cl$cluster, iris[,5])

m <- naiveBayes(iris[,1:4], iris[,5])
table(predict(m, iris[,1:4]), iris[,5])

Dylan