Classification of Iris data set with Naive Bayes in R.
Size: 396.51 KB
Language: en
Added: Mar 30, 2018
Slides: 25 pages
Slide Content
NAÏVE BAYES CLASSIFIER USING R RAKSHIT G DWARAM 205217027 TRILOKI GUPTA 205217006
Naïve B ayes It is a classification technique based on Bayes’ Theorem Naive Bayes classifier assumes that the presence of a particular feature in a class is unrelated to the presence of any other feature.
Why naive Even if these features depend on each other or upon the existence of the other features, all of these properties independently contribute to the probability of an object and that is why it is known as ‘Naive’.
Why use naïve bayes Naive Bayes model is easy to build U seful for very large data sets . O utperform even highly sophisticated classification methods.
Naïve bayes formula Bayes theorem provides a way of calculating posterior probability P( c|x ) from P(c), P(x) and P( x|c ).
Formula
Advantages of naïve bayes It is easy and fast to predict class of test data set . It also perform well in multi class prediction Naive Bayes classifier performs better compare to other models like logistic regression Require less training data. It perform well in case of categorical input variables compared to numerical variable(s.
Disadvantages Zero Frequency bad estimator. Another limitation of Naive Bayes is the assumption of independent predictors.
Applications of Naive Bayes Algorithms Real time Prediction Text classification Spam Filtering Sentiment Analysis
Continued… Multi class Prediction Recommendation System
How to build a basic model using Naive Bayes in R Using library ‘e1071’ Using library ‘caret’
Naïve bayes in r naiveBayes (formula, data, laplace = 0, subset, na.action = na.pass ) The formula is traditional Y~X1+X2+…+ Xn The data is typically a dataframe of numeric or factor variables. laplace provides a smoothing effect subset lets you use only a selection subset of your data based on some boolean filter na.action lets you determine what to do when you hit a missing value in your dataset.
Iris data set
Confusion matrix
Plot on graph naive_iris <- NaiveBayes ( iris$Species ~ ., data = iris) plot( naive_iris )