SlideShare a Scribd company logo
1 of 25
NAÏVE BAYES CLASSIFIER USING R
RAKSHIT G DWARAM 205217027
TRILOKI GUPTA 205217006
Naïve Bayes
• 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
• Useful for very large data sets.
• Outperform 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’
R Code
• library(e1071)
• #Default Paramters
• nb_default <- naiveBayes(response~., data=train[,-4])
• default_pred <- predict(nb_default, test, type="class")
•
• table(default_pred,
test$response,dnn=c("Prediction","Actual"))
• # Actual
• #Prediction 0 1
• # 0 138 16
• # 1 12 14
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)
Precision, Recall and Accuracy
Thank you

More Related Content

What's hot

Classification Algorithm.
Classification Algorithm.Classification Algorithm.
Classification Algorithm.Megha Sharma
 
Classification and prediction in data mining
Classification and prediction in data miningClassification and prediction in data mining
Classification and prediction in data miningEr. Nawaraj Bhandari
 
Data Mining & Applications
Data Mining & ApplicationsData Mining & Applications
Data Mining & ApplicationsFazle Rabbi Ador
 
Linear Regression vs Logistic Regression | Edureka
Linear Regression vs Logistic Regression | EdurekaLinear Regression vs Logistic Regression | Edureka
Linear Regression vs Logistic Regression | EdurekaEdureka!
 
Data warehouse and data mining
Data warehouse and data miningData warehouse and data mining
Data warehouse and data miningPradnya Saval
 
Cross-validation Tutorial: What, how and which?
Cross-validation Tutorial: What, how and which?Cross-validation Tutorial: What, how and which?
Cross-validation Tutorial: What, how and which?Pradeep Redddy Raamana
 
Naïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptxNaïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptxShubham Jaybhaye
 
Data mining slides
Data mining slidesData mining slides
Data mining slidessmj
 
Chapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choicesChapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choicesMaynooth University
 
Application of data mining
Application of data miningApplication of data mining
Application of data miningSHIVANI SONI
 
Ensemble methods in machine learning
Ensemble methods in machine learningEnsemble methods in machine learning
Ensemble methods in machine learningSANTHOSH RAJA M G
 
2.3 bayesian classification
2.3 bayesian classification2.3 bayesian classification
2.3 bayesian classificationKrish_ver2
 

What's hot (20)

Classification Algorithm.
Classification Algorithm.Classification Algorithm.
Classification Algorithm.
 
Naive bayes
Naive bayesNaive bayes
Naive bayes
 
ID3 ALGORITHM
ID3 ALGORITHMID3 ALGORITHM
ID3 ALGORITHM
 
Classification and prediction in data mining
Classification and prediction in data miningClassification and prediction in data mining
Classification and prediction in data mining
 
supervised learning
supervised learningsupervised learning
supervised learning
 
Data Mining & Applications
Data Mining & ApplicationsData Mining & Applications
Data Mining & Applications
 
Linear Regression vs Logistic Regression | Edureka
Linear Regression vs Logistic Regression | EdurekaLinear Regression vs Logistic Regression | Edureka
Linear Regression vs Logistic Regression | Edureka
 
Data warehouse and data mining
Data warehouse and data miningData warehouse and data mining
Data warehouse and data mining
 
Kdd process
Kdd processKdd process
Kdd process
 
Cross-validation Tutorial: What, how and which?
Cross-validation Tutorial: What, how and which?Cross-validation Tutorial: What, how and which?
Cross-validation Tutorial: What, how and which?
 
Naïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptxNaïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptx
 
Data mining slides
Data mining slidesData mining slides
Data mining slides
 
Chapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choicesChapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choices
 
Data mining
Data miningData mining
Data mining
 
2. visualization in data mining
2. visualization in data mining2. visualization in data mining
2. visualization in data mining
 
Bayesian learning
Bayesian learningBayesian learning
Bayesian learning
 
01 Data Mining: Concepts and Techniques, 2nd ed.
01 Data Mining: Concepts and Techniques, 2nd ed.01 Data Mining: Concepts and Techniques, 2nd ed.
01 Data Mining: Concepts and Techniques, 2nd ed.
 
Application of data mining
Application of data miningApplication of data mining
Application of data mining
 
Ensemble methods in machine learning
Ensemble methods in machine learningEnsemble methods in machine learning
Ensemble methods in machine learning
 
2.3 bayesian classification
2.3 bayesian classification2.3 bayesian classification
2.3 bayesian classification
 

Similar to Naive Bayes Classifier using R.

Naïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptxNaïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptxPriyadharshiniG41
 
Machine learning naive bayes and svm.pdf
Machine learning naive bayes and svm.pdfMachine learning naive bayes and svm.pdf
Machine learning naive bayes and svm.pdfSubhamKumar3239
 
UNIT2_NaiveBayes algorithms used in machine learning
UNIT2_NaiveBayes algorithms used in machine learningUNIT2_NaiveBayes algorithms used in machine learning
UNIT2_NaiveBayes algorithms used in machine learningmichaelaaron25322
 
Presentation - Predicting Online Purchases Using Conversion Prediction Modeli...
Presentation - Predicting Online Purchases Using Conversion Prediction Modeli...Presentation - Predicting Online Purchases Using Conversion Prediction Modeli...
Presentation - Predicting Online Purchases Using Conversion Prediction Modeli...Christopher Sneed, MSDS, PMP, CSPO
 
Naive Bayes Classifier.pptx
Naive Bayes Classifier.pptxNaive Bayes Classifier.pptx
Naive Bayes Classifier.pptxramya409687
 
Naive_hehe.pptx
Naive_hehe.pptxNaive_hehe.pptx
Naive_hehe.pptxMahimMajee
 
How Machine Learning Helps Organizations to Work More Efficiently?
How Machine Learning Helps Organizations to Work More Efficiently?How Machine Learning Helps Organizations to Work More Efficiently?
How Machine Learning Helps Organizations to Work More Efficiently?Tuan Yang
 
Towards Detecting Performance Anti-patterns Using Classification Techniques
Towards Detecting Performance Anti-patterns Using Classification TechniquesTowards Detecting Performance Anti-patterns Using Classification Techniques
Towards Detecting Performance Anti-patterns Using Classification TechniquesJames Hill
 
Introduction to deep learning
Introduction to deep learningIntroduction to deep learning
Introduction to deep learningVishwas Lele
 
Thesis Defense
Thesis DefenseThesis Defense
Thesis DefenseSteven Han
 
Classification of URLs
Classification of URLsClassification of URLs
Classification of URLsFANCY ARORA
 
Data mining with Weka
Data mining with WekaData mining with Weka
Data mining with WekaAlbanLevy
 
Prediciting restaurant and popularity based on Yelp Dataset project report
Prediciting restaurant and popularity based on Yelp Dataset  project reportPrediciting restaurant and popularity based on Yelp Dataset  project report
Prediciting restaurant and popularity based on Yelp Dataset project reportALIN BABU
 

Similar to Naive Bayes Classifier using R. (20)

Naïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptxNaïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptx
 
CS3501.pptx
CS3501.pptxCS3501.pptx
CS3501.pptx
 
Machine learning naive bayes and svm.pdf
Machine learning naive bayes and svm.pdfMachine learning naive bayes and svm.pdf
Machine learning naive bayes and svm.pdf
 
UNIT2_NaiveBayes algorithms used in machine learning
UNIT2_NaiveBayes algorithms used in machine learningUNIT2_NaiveBayes algorithms used in machine learning
UNIT2_NaiveBayes algorithms used in machine learning
 
Ml part2
Ml part2Ml part2
Ml part2
 
Presentation - Predicting Online Purchases Using Conversion Prediction Modeli...
Presentation - Predicting Online Purchases Using Conversion Prediction Modeli...Presentation - Predicting Online Purchases Using Conversion Prediction Modeli...
Presentation - Predicting Online Purchases Using Conversion Prediction Modeli...
 
Machine Learning with R
Machine Learning with RMachine Learning with R
Machine Learning with R
 
Naive Bayes Classifier.pptx
Naive Bayes Classifier.pptxNaive Bayes Classifier.pptx
Naive Bayes Classifier.pptx
 
Naive_hehe.pptx
Naive_hehe.pptxNaive_hehe.pptx
Naive_hehe.pptx
 
How Machine Learning Helps Organizations to Work More Efficiently?
How Machine Learning Helps Organizations to Work More Efficiently?How Machine Learning Helps Organizations to Work More Efficiently?
How Machine Learning Helps Organizations to Work More Efficiently?
 
Naive Bayes
Naive BayesNaive Bayes
Naive Bayes
 
Supervised Learning.pptx
Supervised Learning.pptxSupervised Learning.pptx
Supervised Learning.pptx
 
Naive.pdf
Naive.pdfNaive.pdf
Naive.pdf
 
Towards Detecting Performance Anti-patterns Using Classification Techniques
Towards Detecting Performance Anti-patterns Using Classification TechniquesTowards Detecting Performance Anti-patterns Using Classification Techniques
Towards Detecting Performance Anti-patterns Using Classification Techniques
 
Introduction to deep learning
Introduction to deep learningIntroduction to deep learning
Introduction to deep learning
 
Thesis Defense
Thesis DefenseThesis Defense
Thesis Defense
 
Supervised models
Supervised modelsSupervised models
Supervised models
 
Classification of URLs
Classification of URLsClassification of URLs
Classification of URLs
 
Data mining with Weka
Data mining with WekaData mining with Weka
Data mining with Weka
 
Prediciting restaurant and popularity based on Yelp Dataset project report
Prediciting restaurant and popularity based on Yelp Dataset  project reportPrediciting restaurant and popularity based on Yelp Dataset  project report
Prediciting restaurant and popularity based on Yelp Dataset project report
 

More from Triloki Gupta

GCP Deployment- Vertex AI
GCP Deployment- Vertex AIGCP Deployment- Vertex AI
GCP Deployment- Vertex AITriloki Gupta
 
Speaker identification
Speaker identificationSpeaker identification
Speaker identificationTriloki Gupta
 
Sign Language Recognition based on Hands symbols Classification
Sign Language Recognition based on Hands symbols ClassificationSign Language Recognition based on Hands symbols Classification
Sign Language Recognition based on Hands symbols ClassificationTriloki Gupta
 
Introduction to pig.
Introduction to pig.Introduction to pig.
Introduction to pig.Triloki Gupta
 
Enhancement of Old Images and Documents by Digital Image Processing Techniques.
Enhancement of Old Images and Documents by Digital Image Processing Techniques.Enhancement of Old Images and Documents by Digital Image Processing Techniques.
Enhancement of Old Images and Documents by Digital Image Processing Techniques.Triloki Gupta
 

More from Triloki Gupta (7)

GCP Deployment- Vertex AI
GCP Deployment- Vertex AIGCP Deployment- Vertex AI
GCP Deployment- Vertex AI
 
Flask-Python
Flask-PythonFlask-Python
Flask-Python
 
Speaker identification
Speaker identificationSpeaker identification
Speaker identification
 
Sign Language Recognition based on Hands symbols Classification
Sign Language Recognition based on Hands symbols ClassificationSign Language Recognition based on Hands symbols Classification
Sign Language Recognition based on Hands symbols Classification
 
Introduction to pig.
Introduction to pig.Introduction to pig.
Introduction to pig.
 
Meta analysis.
Meta analysis.Meta analysis.
Meta analysis.
 
Enhancement of Old Images and Documents by Digital Image Processing Techniques.
Enhancement of Old Images and Documents by Digital Image Processing Techniques.Enhancement of Old Images and Documents by Digital Image Processing Techniques.
Enhancement of Old Images and Documents by Digital Image Processing Techniques.
 

Recently uploaded

ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxolyaivanovalion
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 

Recently uploaded (20)

ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 

Naive Bayes Classifier using R.

  • 1. NAÏVE BAYES CLASSIFIER USING R RAKSHIT G DWARAM 205217027 TRILOKI GUPTA 205217006
  • 2. Naïve Bayes • 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.
  • 3. 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’.
  • 4. Why use naïve bayes • Naive Bayes model is easy to build • Useful for very large data sets. • Outperform even highly sophisticated classification methods.
  • 5. 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).
  • 7. 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.
  • 8. Disadvantages • Zero Frequency • bad estimator. • Another limitation of Naive Bayes is the assumption of independent predictors.
  • 9. Applications of Naive Bayes Algorithms • Real time Prediction • Text classification • Spam Filtering • Sentiment Analysis
  • 10. Continued… • Multi class Prediction • Recommendation System
  • 11. How to build a basic model using Naive Bayes in R • Using library ‘e1071’ • Using library ‘caret’
  • 12. R Code • library(e1071) • #Default Paramters • nb_default <- naiveBayes(response~., data=train[,-4]) • default_pred <- predict(nb_default, test, type="class") • • table(default_pred, test$response,dnn=c("Prediction","Actual")) • # Actual • #Prediction 0 1 • # 0 138 16 • # 1 12 14
  • 13. 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.
  • 15.
  • 16.
  • 18. Plot on graph • naive_iris <- NaiveBayes(iris$Species ~ ., data = iris) • plot(naive_iris)
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.