Naive Bayes
Naive Bayes is an algorithm that uses probability to classify the data according to Bayes theorem for strong independence of the features. Bayes theorem estimates the probability of an event based on prior conditions. So, overall, we use a set of feature values to estimate a value assuming the same conditions hold true when those features have similar values.
Naive Bayes using R
Our first implementation of naive Bayes uses the R programming language. The R implementation of the algorithm is encoded in the e1071 library. e1071 appears to have been the department identifier at the school where the package was developed.
We first install the package, and load the library:
#install.packages("e1071", repos="http://cran.r-project.org")
library(e1071)
library(caret)
set.seed(7317)
data(iris)Some notes on these steps:
- The
install.packagescall is commented out as we don't want to run this every time we run the script. e1071is the naive Bayes algorithm package.- The
caretpackage contains...