SlideShare a Scribd company logo
2
Most read
4
Most read
5
Most read
Data Analytics with Data Science-
Naïve Bayes Classifier Algorithm
By
Dr. D.Shunmuga Kumari,
Assistant Professor,
Department of information Technology,
Data Analytics with Data Science Algorithm
• Supervised learning is a machine learning method in which models are trained using labeled
data.
• Labeled data is data that has been tagged with a correct answer or classification.
• Once the training is completed, we will test the model by giving the new set of animal. The
model will identify the animal and predict the output using a suitable algorithm.
• Unsupervised learning is another machine learning method in which patterns inferred from
the unlabeled input data.
• The goal of unsupervised learning is to find the structure and patterns from the input data.
• Unsupervised learning does not need any supervision. Instead, it finds patterns from the
data by its own.
• Naïve Bayes algorithm is a supervised learning algorithm, which is based on
Bayes theorem and used for solving classification problems.
• It is mainly used in text classification that includes a high-dimensional
training dataset.
• Naïve Bayes Classifier is one of the simple and most effective Classification
algorithms which helps in building the fast machine learning models that can
make quick predictions.
• It is a probabilistic classifier, which means it predicts on the basis of the
probability of an object.
• Some popular examples of Naïve Bayes Algorithm are spam filtration,
Sentimental analysis, and classifying articles.
Why is it called Naïve Bayes?
• The Naïve Bayes algorithm is comprised of two words Naïve and Bayes,
• Which can be described as:
Naïve: It is called Naïve because it assumes that the occurrence of a certain feature is
independent of the occurrence of other features. Such as if the fruit is identified on the bases of
color, shape, and taste, then red, spherical, and sweet fruit is recognized as an apple.
• Hence each feature individually contributes to identify that it is an apple without depending
on each other.
Bayes: It is called Bayes because it depends on the principle of Bayes' Theorem.
Bayes' Theorem:
Bayes' theorem is also known as Bayes' Rule or Bayes' law, which is used to determine the
probability of a hypothesis with prior knowledge.
It depends on the conditional probability.
The formula for Bayes' theorem is given as:
Where,
 P(A|B) is Posterior probability: Probability of hypothesis A on the
observed event B.
 P(B|A) is Likelihood probability: Probability of the evidence given
that the probability of a hypothesis is true.
 P(A) is Prior Probability: Probability of hypothesis before
observing the evidence.
 P(B) is Marginal Probability: Probability of Evidence.
Working of Naïve Bayes' Classifier:
Working of Naïve Bayes' Classifier can be understood with the help of the below example:
Suppose we have a dataset of weather conditions and corresponding target variable "Play".
So using this dataset we need to decide that whether we should play or not on a particular
day according to the weather conditions.
So to solve this problem, we need to follow the below steps:
Convert the given dataset into frequency tables.
Generate Likelihood table by finding the probabilities of given features.
Now, use Bayes theorem to calculate the posterior probability.
Problem: If the weather is sunny, then the Player should play or not?
Solution: To solve this, first consider the below dataset:
Outlook Play
0 Rainy Yes
1 Sunny Yes
2 Overcast Yes
3 Overcast Yes
4 Sunny No
5 Rainy Yes
6 Sunny Yes
7 Overcast Yes
8 Rainy No
9 Sunny No
10 Sunny Yes
11 Rainy No
12 Overcast Yes
13 Overcast Yes
I. Frequency table for the Weather Conditions:
Weather Yes No
Overcast 5 0
Rainy 2 2
Sunny 3 2
Total 10 5
11
II Likelihood table weather condition:
Weather No Yes
Overcast 0 5 5/14= 0.35
Rainy 2 2 4/14=0.29
Sunny 2 3 5/14=0.35
All 4/14=0.29 10/14=0.71
12
III.Applying Bayes'theorem:
P(Yes | Sunny)= P(Sunny | Yes)*P(Yes)/P(Sunny)
P(Sunny | Yes)= 3/10= 0.3
P(Sunny)= 0.35
P(Yes)=0.71
So P(Yes |Sunny) = 0.3*0.71/0.35= 0.60
P(No | Sunny)= P(Sunny | No)*P(No)/P(Sunny)
P(Sunny | NO)= 2/4=0.5
P(No)= 0.29
P(Sunny)= 0.35
So P(No | Sunny)= 0.5*0.29/0.35 = 0.41
So as we can see from the above calculation that P(Yes | Sunny)>P(No | Sunny)
Hence on a Sunny day, Player can play the game.
13
Advantages of Naïve Bayes Classifier:
• Naïve Bayes is one of the fast and easy ML algorithms to predict a class of
datasets.
• It can be used for Binary as well as Multi-class Classifications.
• It performs well in Multi-class predictions as compared to the other Algorithms.
• It is the most popular choice for text classification problems.
Disadvantages of Naïve Bayes Classifier:
• Naive Bayes assumes that all features are independent or unrelated, so it cannot
learn the relationship between features.
14
Applications of Naïve Bayes Classifier:
It is used for Credit Scoring.
It is used in medical data classification.
It can be used in real-time predictions because Naïve Bayes Classifier is an eager
learner.
It is used in Text classification such as Spam filtering and Sentiment analysis.

More Related Content

PPTX
Naïve Bayes Classifier Algorithm.pptx
PPTX
Naïve Bayes Classification (Data Mining)
PPTX
Navies bayes
PPTX
Bayer's Theorem Naive Bayer's classifier
PDF
Naive.pdf
PPTX
Naïve Bayes Classifier Algorithm.pptx
PPTX
Naive Bayesian classifier Naive Bayesian classifier Naive Bayesian classifier
PPTX
Naive_hehe.pptx
Naïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classification (Data Mining)
Navies bayes
Bayer's Theorem Naive Bayer's classifier
Naive.pdf
Naïve Bayes Classifier Algorithm.pptx
Naive Bayesian classifier Naive Bayesian classifier Naive Bayesian classifier
Naive_hehe.pptx

Similar to Data Analytics with Data Science Algorithm (20)

PDF
Naive Bayes
PPTX
Introduction to Naive Bayes Algorithm ppt
PDF
Unit3_Classification_BAYES_Machine_Learning.pdf
PDF
Machine learning naive bayes and svm.pdf
PPT
UNIT2_NaiveBayes algorithms used in machine learning
PDF
Naïve Bayes Machine Learning Classification with R Programming: A case study ...
PPTX
Naive Bayes_1.pptx Slides of NB in classical machine learning
PPT
9-Decision Tree Induction-23-01-2025.ppt
PPTX
"Naive Bayes Classifier" @ Papers We Love Bucharest
PPTX
Naive Bayes Presentation
PPT
NaiveBayes_machine-learning(basic_ppt).ppt
PPT
bayes answer jejisiowwoowwksknejejrjejej
PPT
bayesNaive.ppt
PPT
bayesNaive.ppt
PPT
bayesNaive algorithm in machine learning
PPT
Unit-2.ppt
PDF
19BayesTheoremClassification19BayesTheoremClassification.ppt
PPT
NaiveBayes this is more functioonal and extraction of same version
PPT
NaiveBayes classifier in artificial inteeligence.ppt
PPT
NaiveBayes classifier for data classification
Naive Bayes
Introduction to Naive Bayes Algorithm ppt
Unit3_Classification_BAYES_Machine_Learning.pdf
Machine learning naive bayes and svm.pdf
UNIT2_NaiveBayes algorithms used in machine learning
Naïve Bayes Machine Learning Classification with R Programming: A case study ...
Naive Bayes_1.pptx Slides of NB in classical machine learning
9-Decision Tree Induction-23-01-2025.ppt
"Naive Bayes Classifier" @ Papers We Love Bucharest
Naive Bayes Presentation
NaiveBayes_machine-learning(basic_ppt).ppt
bayes answer jejisiowwoowwksknejejrjejej
bayesNaive.ppt
bayesNaive.ppt
bayesNaive algorithm in machine learning
Unit-2.ppt
19BayesTheoremClassification19BayesTheoremClassification.ppt
NaiveBayes this is more functioonal and extraction of same version
NaiveBayes classifier in artificial inteeligence.ppt
NaiveBayes classifier for data classification
Ad

More from kumari36 (20)

PPTX
Transaction of program execution updates
PPTX
ER-Model specification logical structure
DOCX
Virtualize of IO Devices .docx
DOCX
VIRTUALIZATION STRUCTURES TOOLS.docx
DOCX
Operating System extension.docx
DOCX
Levels of Virtualization.docx
PDF
Overview of java Language-3.pdf
PDF
Java Evolution-2.pdf
PDF
Inheritance in Java.pdf
PDF
Constructors in Java (2).pdf
PDF
Chapter4-var.pdf
PDF
softwareMaintenance.pdf
PDF
testing.pdf
PDF
Debugging.pdf
PDF
QualityAssurance.pdf
PPTX
Prediction of heart disease using machine learning.pptx
PPTX
Fast Wavelet Based Image Characterization for Highly Adaptive Image Retrieval...
PPTX
Presentation1.4.pptx
PPTX
Presentation1.3.pptx
PPTX
Cloud 1.2.pptx
Transaction of program execution updates
ER-Model specification logical structure
Virtualize of IO Devices .docx
VIRTUALIZATION STRUCTURES TOOLS.docx
Operating System extension.docx
Levels of Virtualization.docx
Overview of java Language-3.pdf
Java Evolution-2.pdf
Inheritance in Java.pdf
Constructors in Java (2).pdf
Chapter4-var.pdf
softwareMaintenance.pdf
testing.pdf
Debugging.pdf
QualityAssurance.pdf
Prediction of heart disease using machine learning.pptx
Fast Wavelet Based Image Characterization for Highly Adaptive Image Retrieval...
Presentation1.4.pptx
Presentation1.3.pptx
Cloud 1.2.pptx
Ad

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
master seminar digital applications in india
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
01-Introduction-to-Information-Management.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Pre independence Education in Inndia.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Institutional Correction lecture only . . .
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Cell Structure & Organelles in detailed.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Complications of Minimal Access Surgery at WLH
102 student loan defaulters named and shamed – Is someone you know on the list?
Final Presentation General Medicine 03-08-2024.pptx
master seminar digital applications in india
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
STATICS OF THE RIGID BODIES Hibbelers.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
01-Introduction-to-Information-Management.pdf
Microbial disease of the cardiovascular and lymphatic systems
Pre independence Education in Inndia.pdf
Insiders guide to clinical Medicine.pdf
Computing-Curriculum for Schools in Ghana
Anesthesia in Laparoscopic Surgery in India
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Institutional Correction lecture only . . .
Microbial diseases, their pathogenesis and prophylaxis
FourierSeries-QuestionsWithAnswers(Part-A).pdf
GDM (1) (1).pptx small presentation for students
Cell Structure & Organelles in detailed.
2.FourierTransform-ShortQuestionswithAnswers.pdf
Complications of Minimal Access Surgery at WLH

Data Analytics with Data Science Algorithm

  • 1. Data Analytics with Data Science- Naïve Bayes Classifier Algorithm By Dr. D.Shunmuga Kumari, Assistant Professor, Department of information Technology,
  • 3. • Supervised learning is a machine learning method in which models are trained using labeled data. • Labeled data is data that has been tagged with a correct answer or classification. • Once the training is completed, we will test the model by giving the new set of animal. The model will identify the animal and predict the output using a suitable algorithm.
  • 4. • Unsupervised learning is another machine learning method in which patterns inferred from the unlabeled input data. • The goal of unsupervised learning is to find the structure and patterns from the input data. • Unsupervised learning does not need any supervision. Instead, it finds patterns from the data by its own.
  • 5. • Naïve Bayes algorithm is a supervised learning algorithm, which is based on Bayes theorem and used for solving classification problems. • It is mainly used in text classification that includes a high-dimensional training dataset. • Naïve Bayes Classifier is one of the simple and most effective Classification algorithms which helps in building the fast machine learning models that can make quick predictions. • It is a probabilistic classifier, which means it predicts on the basis of the probability of an object. • Some popular examples of Naïve Bayes Algorithm are spam filtration, Sentimental analysis, and classifying articles.
  • 6. Why is it called Naïve Bayes? • The Naïve Bayes algorithm is comprised of two words Naïve and Bayes, • Which can be described as: Naïve: It is called Naïve because it assumes that the occurrence of a certain feature is independent of the occurrence of other features. Such as if the fruit is identified on the bases of color, shape, and taste, then red, spherical, and sweet fruit is recognized as an apple. • Hence each feature individually contributes to identify that it is an apple without depending on each other. Bayes: It is called Bayes because it depends on the principle of Bayes' Theorem. Bayes' Theorem: Bayes' theorem is also known as Bayes' Rule or Bayes' law, which is used to determine the probability of a hypothesis with prior knowledge. It depends on the conditional probability.
  • 7. The formula for Bayes' theorem is given as: Where,  P(A|B) is Posterior probability: Probability of hypothesis A on the observed event B.  P(B|A) is Likelihood probability: Probability of the evidence given that the probability of a hypothesis is true.  P(A) is Prior Probability: Probability of hypothesis before observing the evidence.  P(B) is Marginal Probability: Probability of Evidence.
  • 8. Working of Naïve Bayes' Classifier: Working of Naïve Bayes' Classifier can be understood with the help of the below example: Suppose we have a dataset of weather conditions and corresponding target variable "Play". So using this dataset we need to decide that whether we should play or not on a particular day according to the weather conditions. So to solve this problem, we need to follow the below steps: Convert the given dataset into frequency tables. Generate Likelihood table by finding the probabilities of given features. Now, use Bayes theorem to calculate the posterior probability.
  • 9. Problem: If the weather is sunny, then the Player should play or not? Solution: To solve this, first consider the below dataset: Outlook Play 0 Rainy Yes 1 Sunny Yes 2 Overcast Yes 3 Overcast Yes 4 Sunny No 5 Rainy Yes 6 Sunny Yes 7 Overcast Yes 8 Rainy No 9 Sunny No 10 Sunny Yes 11 Rainy No 12 Overcast Yes 13 Overcast Yes
  • 10. I. Frequency table for the Weather Conditions: Weather Yes No Overcast 5 0 Rainy 2 2 Sunny 3 2 Total 10 5
  • 11. 11 II Likelihood table weather condition: Weather No Yes Overcast 0 5 5/14= 0.35 Rainy 2 2 4/14=0.29 Sunny 2 3 5/14=0.35 All 4/14=0.29 10/14=0.71
  • 12. 12 III.Applying Bayes'theorem: P(Yes | Sunny)= P(Sunny | Yes)*P(Yes)/P(Sunny) P(Sunny | Yes)= 3/10= 0.3 P(Sunny)= 0.35 P(Yes)=0.71 So P(Yes |Sunny) = 0.3*0.71/0.35= 0.60 P(No | Sunny)= P(Sunny | No)*P(No)/P(Sunny) P(Sunny | NO)= 2/4=0.5 P(No)= 0.29 P(Sunny)= 0.35 So P(No | Sunny)= 0.5*0.29/0.35 = 0.41 So as we can see from the above calculation that P(Yes | Sunny)>P(No | Sunny) Hence on a Sunny day, Player can play the game.
  • 13. 13 Advantages of Naïve Bayes Classifier: • Naïve Bayes is one of the fast and easy ML algorithms to predict a class of datasets. • It can be used for Binary as well as Multi-class Classifications. • It performs well in Multi-class predictions as compared to the other Algorithms. • It is the most popular choice for text classification problems. Disadvantages of Naïve Bayes Classifier: • Naive Bayes assumes that all features are independent or unrelated, so it cannot learn the relationship between features.
  • 14. 14 Applications of Naïve Bayes Classifier: It is used for Credit Scoring. It is used in medical data classification. It can be used in real-time predictions because Naïve Bayes Classifier is an eager learner. It is used in Text classification such as Spam filtering and Sentiment analysis.