[R] How to do Naive Bayes in R?
spencer.graves at prodsyse.com
Wed May 6 22:44:05 CEST 2009
help.search('bayes') only searches installed packages.
To go beyond that, you might try the following:
bayes <- RSiteSearch.function('bayes', 999)
# This produces a Parato analysis of packages in terms of references
# to the search term in their help pages.
# In this example, it does NOT find 'e1071'.
n.b <- RSiteSearch.function('naive Bayes')
# This displays a table in a web browser sorted by package and "Score"
# with links to the help pages via the web.
Beyond this, "www.r-project.org -> Documentation: Books" provides
a list of books about various aspects of R, including several references
Hope this helps.
Dylan Beaudette wrote:
> 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)
> table(cl$cluster, iris[,5])
> m <- naiveBayes(iris[,1:4], iris[,5])
> table(predict(m, iris[,1:4]), iris[,5])
More information about the R-help