[R] How to do Naive Bayes in R?
debeaudette at ucdavis.edu
Wed May 6 22:20:29 CEST 2009
On Wednesday 06 May 2009, Tim LIU wrote:
> I am wondering if anybody here have a simple example in R for Naive
> For example, I can do k-means clustering on the "iris" data -
> cl <- kmeans(iris[,1:4], 3)
> But how to do Naive Bayes classification in the same "iris" data?
> Many thanks!
# start here:
# in which you will find:
# which means:
# and compared to your example:
cl <- kmeans(iris[,1:4], 3)
m <- naiveBayes(iris[,1:4], iris[,5])
table(predict(m, iris[,1:4]), iris[,5])
Soil Resource Laboratory
University of California at Davis
More information about the R-help