November 2016
Beginner to intermediate
959 pages
43h 46m
English
The e1071 package contains the naiveBayes function for the Naïve Bayes classification.
If you do not already have the e1071 and
caret packages, install them now. Download the data files for this chapter from the book's website and place the electronics-purchase.csv file in your R working directory. Naïve Bayes requires all the variables to be categorical. So, if needed, you should first convert all variables accordingly—refer to the recipe Binning numerical data in Chapter, Acquire and Prepare the Ingredients – Your Data.
To classify using the Naïve Bayes method, follow these steps:
e1071 and caret packages:> library(e1071) > library(caret)
> ep <- read.csv("electronics-purchase.csv") ...Read now
Unlock full access