SlideShare a Scribd company logo
1 of 36
NAIVE BAYES CLASSIFIER
Nitin Aggarwal
Software Consultant
Knoldus Software LLP
Agenda
● What is Conditional Probability ?
● What is Bayes Theorem?
● What is NAIVE BAYES CLASSIFIER?
● Types of Naive Bayes Algorithm.
Conditional Probability
1. In probability theory, conditional probability is a measure of the probability
of an event given that another event has already occurred.
2. If the event of interest is A and the event B is assumed to have occurred,
"the conditional probability of A given B", or "the probability of A under the
condition B", is usually written as P(A|B), or sometimes PB(A).
Examples
Chances of cough
The probability that any given person has a cough on any given day maybe
only 5%. But if we know or assume that the person has a cold, then they are
much more likely to be coughing. The conditional probability of coughing
given that person have a cold might be a much higher 75%.
Marbles in a Bag
2 blue and 3 red marbles are in a bag.
What are the chances of getting a blue marble?
???
Marbles in a Bag
2 blue and 3 red marbles are in a bag.
What are the chances of getting a blue marble?
Answer: - The chance is 2 in 5
But after taking one out of these chances,
situation may change!
So the next time:
1. if we got a red marble before, then the chance of a blue marble next is 2
in 4
2. if we got a blue marble before, then the chance of a blue marble next is 1
in 4
Likewise:-
Drawing a second ace from a deck given we got the first ace
Finding the probability of having a disease given you were tested positive
Finding the probability of liking Harry Potter given we know the person likes
fiction.
Bayes Theorem
1. In probability theory and statistics, Bayes’ theorem (alternatively Bayes’
law or Bayes' rule) describes the probability of an event, based on prior
knowledge of conditions that might be related to the event.
2. For example, if cancer is related to age, then, using Bayes’ theorem, a
person’s age can be used to more accurately to assess the probability
that they have cancer, compared to the assessment of the probability of
cancer made without knowledge of the person's age.
The Formula for Bayes’ theorem
where
1. P(H) is the probability of hypothesis H being true. This is known as the
prior probability.
2. P(E) is the probability of the evidence(regardless of the hypothesis).
3. P(E|H) is the probability of the evidence given that hypothesis is true.
4. P(H|E) is the probability of the hypothesis given that the evidence is
there.
Examples
Suppose there are three bowls B1, B2, B3 and bowl B1 has 2 red and 4 blue
coins; bowl B2 has 1 red and 2 blue coins; bowl B3 contains 5 red and 4 blue
coins.Suppose the probabilities for selecting the bowls is not the same but
are:-
● P(B1) = 1/3
● P(B2) = 1/6
● P(B3) = 1/2
Now, let us compute, assuming that a red coin was drawn what will be the
probability that it came from bowl B1.
In mathematics teams, we need to find out P(B1|R) = ???
And according to Bayes’ theorem
P(B1|R) = P(R|B1) * P(B1) / P(R)
For that first, we need to calculate some probabilities which are:-
● Probability to select a red coin i.e P(R)
● Probability to select the bowl 1 (B1) i.e P(B1) which is already given 1/3
● Probability to select a red coin from B1 i.e P(R|B1)
P(R)
= P(B1 R) + (B2 R) + P(B3 R)⋂ ⋂ ⋂
where
● P(B1 R) is probability to select bowl 1 and red coin⋂
● P(B2 R) is probability to select bowl 2 and red coin⋂
● P(B3 R) is probability to select bowl 3 and red coin⋂
= P(selecting B1) * P(Number of Red coins / total number of coins in B1 ) +
P(selecting B2) * P(Number of Red coins in B2 / total number of coins in B2 )
+ P(selecting B3) * P(Number of Red coins in B3/ total number of coins in
B3 )
= 1/3 * 2/6 + 1/6 * 1/3 + 1/2* 5/9
= 4/9
So P(R) = 4/9
P(R|B1)
The probability of selecting a red coin given that it will be drawn from B1 is 2/6
P(B1) was given i.e 1/3.
By putting all the values in formula:
P(B1|R) = (2/6 *1/3) / 4/9 = 2/8 = 0.25
So we can say that if a red coin was drawn that it will be 25% chances
that it was drawn from bowl 1 i.e B1.
NAIVE BAYES CLASSIFIER
● Naive Bayes is a kind of classifier which uses the Bayes Theorem.
● It predicts membership probabilities for each class such as the probability
that given record or data point belongs to a particular class.
● The class with the highest probability is considered as the most likely
class. This is also known as Maximum A Posteriori (MAP).
MAP(H)
= max( P(H|E) )
= max( (P(E|H)*P(H))/P(E))
= max(P(E|H)*P(H))
P(E) is evidence probability, and it is used to normalize the result. It remains
same so, removing it won’t affect.
Assumption
Naive Bayes classifier assumes that all the features are unrelated to
each other. Presence or absence of a feature does not influence the
presence or absence of any other feature.
“A fruit may be considered to be an apple if it is red, round, and about 4″ in
diameter. Even if these features depend on each other or upon the existence
of the other features, a naive Bayes classifier considers all of these properties
to independently contribute to the probability that this fruit is an apple.”
In real datasets, we test a hypothesis given multiple evidence(feature). So,
calculations become complicated. To simplify the work, the feature
independence approach is used to ‘uncouple’ multiple evidence and treat
each as an independent one.
P(H|Multiple Evidences) = P(E1| H)* P(E2|H) ……*P(En|H) * P(H) /
P(Multiple Evidences)
For understanding a theoretical concept, the best procedure is to try it on an
example.
Let’s consider a training dataset with 1500 records and 3 classes. We
presume that there are no missing values in our data. We have
We have 3 classes associated with Animal Types:
● Parrot,
● Dog,
● Fish.
The Predictor features set consists of 4 features as
● Swim
● Wings
● Green Color
● Dangerous Teeth.
Swim,Wings,Green Color, Dangerous Teeth. All the features are categorical
variables with either of the 2 values: T(True) or F( False).
The above table shows a frequency table of our data. In our training data:
● Parrots have 50(10%) value for Swim, i.e., 10% parrot can swim
according to our data, 500 out of 500(100%) parrots have wings, 400 out
of 500(80%) parrots are Green and 0(0%) parrots have Dangerous
Teeth.
● Classes with Animal type Dogs shows that 450 out of 500(90%) can
swim, 0(0%) dogs have wings, 0(0%) dogs are of Green color and 500
out of 500(100%) dogs have Dangerous Teeth.
● Classes with Animal type Fishes shows that 500 out of 500(100%) can
swim, 0(0%) fishes have wings, 100(20%) fishes are of Green color and
50 out of 500(10%) Fishes have Dangerous Teeth.
Now, it’s time to work on predict classes using the Naive Bayes model.
We have taken 2 records that have values in their feature set, but the target
variable needs to predicted.
● We have to predict animal type using the feature values. We have to
predict whether the animal is a Dog, a Parrot or a Fish
P(H|Multiple Evidences) = P(E1| H)* P(E2|H) ……*P(En|H) * P(H) /
P(Multiple Evidences)
Let’s consider the first record.
The Evidence here is Swim & Green. The Hypothesis can be an animal type
to be Dog, Parrot, Fish.
For Hypothesis testing for the animal to be a Dog:
P(Dog | Swim, Green) = P(Swim|Dog) * P(Green|Dog) * P(Dog) / P(Swim,
Green)
= 0.9 * 0 * 0.333 / P(Swim, Green)
= 0
For Hypothesis testing for the animal to be a Parrot:
P(Parrot| Swim, Green) = P(Swim|Parrot) * P(Green|Parrot) * P(Parrot) /
P(Swim, Green)
= 0.1 * 0.80 * 0.333 / P(Swim, Green)
= 0.0264/ P(Swim, Green)
For Hypothesis testing for the animal to be a Fish:
P(Fish| Swim, Green) = P(Swim|Fish) * P(Green|Fish) * P(Fish) / P(Swim,
Green)
= 1 * 0.2 * 0.333 / P(Swim, Green)
= 0.0666/ P(Swim, Green)
The denominator of all the above calculations is same i.e, P(Swim, Green).
The value of P(Fish| Swim, Green) is greater that P(Parrot| Swim, Green).
Using Naive Bayes, we can predict that the class of this record is Fish.
Let’s consider the second record.
The Evidence here is Swim, Green & Teeth. The Hypothesis can be an
animal type to be Dog, Parrot, Fish.
For Hypothesis testing for the animal to be a Dog:
P(Dog | Swim, Green, Teeth) = P(Swim|Dog) * P(Green|Dog) * P(Teeth|Dog) *
P(Dog) / P(Swim, Green, Teeth)
= 0.9 * 0 * 1 * 0.333 / P(Swim, Green, Teeth) = 0
For Hypothesis testing for the animal to be a Parrot:
P(Parrot| Swim, Green, Teeth) = P(Swim|Parrot) * P(Green|Parrot)* P(Teeth|
Parrot) * P(Parrot) / P(Swim, Green, Teeth)
= 0.1 * 0.80 * 0 *0.333 / P(Swim, Green, Teeth)
= 0
For Hypothesis testing for the animal to be a Fish:
P(Fish|Swim, Green, Teeth) = P(Swim|Fish) * P(Green|Fish) * P(Teeth|Fish)
*P(Fish) / P(Swim, Green, Teeth)
= 1 * 0.2 * 0.1 * 0.333 / P(Swim, Green, Teeth)
= 0.00666 / P(Swim, Green, Teeth)
The value of P(Fish| Swim, Green, Teeth) is the only positive value greater
than 0. Using Naive Bayes, we can predict that the class of this record is
Fish.
Types of Naive Bayes Algorithm
Gaussian: It is used in classification and it assumes that features follow a
normal distribution.
Bernoulli: The binomial model is useful if your feature vectors are binary (i.e.
zeros and ones). One application would be text classification with ‘bag of
words’ model where the 1s & 0s are “word occurs in the document” and “word
does not occur in the document” respectively.
MultiNomial Naive Bayes is preferred to use on data that is multinomially
distributed.
For example, let’s say, we have a text classification problem. Here we can
consider bernoulli trials which is one step further and instead of “word
occurring in the document”, we have “count how often word occurs in the
document”, you can think of it as “number of times outcome number x_i is
observed over the n trials”.
NAIVE BAYES CLASSIFIER

More Related Content

What's hot

2.6 support vector machines and associative classifiers revised
2.6 support vector machines and associative classifiers revised2.6 support vector machines and associative classifiers revised
2.6 support vector machines and associative classifiers revisedKrish_ver2
 
Deep Reinforcement Learning
Deep Reinforcement LearningDeep Reinforcement Learning
Deep Reinforcement LearningUsman Qayyum
 
Naive bayes
Naive bayesNaive bayes
Naive bayesumeskath
 
Random forest
Random forestRandom forest
Random forestUjjawal
 
Machine Learning-Linear regression
Machine Learning-Linear regressionMachine Learning-Linear regression
Machine Learning-Linear regressionkishanthkumaar
 
Uncertain Knowledge and Reasoning in Artificial Intelligence
Uncertain Knowledge and Reasoning in Artificial IntelligenceUncertain Knowledge and Reasoning in Artificial Intelligence
Uncertain Knowledge and Reasoning in Artificial IntelligenceExperfy
 
Lecture9 - Bayesian-Decision-Theory
Lecture9 - Bayesian-Decision-TheoryLecture9 - Bayesian-Decision-Theory
Lecture9 - Bayesian-Decision-TheoryAlbert Orriols-Puig
 
Belief Networks & Bayesian Classification
Belief Networks & Bayesian ClassificationBelief Networks & Bayesian Classification
Belief Networks & Bayesian ClassificationAdnan Masood
 
Bayes Classification
Bayes ClassificationBayes Classification
Bayes Classificationsathish sak
 
Linear regression
Linear regressionLinear regression
Linear regressionMartinHogg9
 
Classification Algorithm.
Classification Algorithm.Classification Algorithm.
Classification Algorithm.Megha Sharma
 
Decision Trees
Decision TreesDecision Trees
Decision TreesStudent
 
Machine Learning with Decision trees
Machine Learning with Decision treesMachine Learning with Decision trees
Machine Learning with Decision treesKnoldus Inc.
 
Support vector machines (svm)
Support vector machines (svm)Support vector machines (svm)
Support vector machines (svm)Sharayu Patil
 
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...Edureka!
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning Mohammad Junaid Khan
 

What's hot (20)

2.6 support vector machines and associative classifiers revised
2.6 support vector machines and associative classifiers revised2.6 support vector machines and associative classifiers revised
2.6 support vector machines and associative classifiers revised
 
Ensemble methods
Ensemble methods Ensemble methods
Ensemble methods
 
Deep Reinforcement Learning
Deep Reinforcement LearningDeep Reinforcement Learning
Deep Reinforcement Learning
 
Naive bayes
Naive bayesNaive bayes
Naive bayes
 
Random forest
Random forestRandom forest
Random forest
 
Machine Learning-Linear regression
Machine Learning-Linear regressionMachine Learning-Linear regression
Machine Learning-Linear regression
 
Uncertain Knowledge and Reasoning in Artificial Intelligence
Uncertain Knowledge and Reasoning in Artificial IntelligenceUncertain Knowledge and Reasoning in Artificial Intelligence
Uncertain Knowledge and Reasoning in Artificial Intelligence
 
Lecture9 - Bayesian-Decision-Theory
Lecture9 - Bayesian-Decision-TheoryLecture9 - Bayesian-Decision-Theory
Lecture9 - Bayesian-Decision-Theory
 
Belief Networks & Bayesian Classification
Belief Networks & Bayesian ClassificationBelief Networks & Bayesian Classification
Belief Networks & Bayesian Classification
 
Bayes Classification
Bayes ClassificationBayes Classification
Bayes Classification
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Support Vector Machines ( SVM )
Support Vector Machines ( SVM ) Support Vector Machines ( SVM )
Support Vector Machines ( SVM )
 
Classification Algorithm.
Classification Algorithm.Classification Algorithm.
Classification Algorithm.
 
K - Nearest neighbor ( KNN )
K - Nearest neighbor  ( KNN )K - Nearest neighbor  ( KNN )
K - Nearest neighbor ( KNN )
 
Decision Trees
Decision TreesDecision Trees
Decision Trees
 
Machine Learning with Decision trees
Machine Learning with Decision treesMachine Learning with Decision trees
Machine Learning with Decision trees
 
Support vector machines (svm)
Support vector machines (svm)Support vector machines (svm)
Support vector machines (svm)
 
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning
 

Similar to NAIVE BAYES CLASSIFIER

Acem bayes classifier
Acem bayes classifierAcem bayes classifier
Acem bayes classifierAastha Kohli
 
2013-1 Machine Learning Lecture 03 - Andrew Moore - a gentle introduction …
2013-1 Machine Learning Lecture 03 - Andrew Moore - a gentle introduction …2013-1 Machine Learning Lecture 03 - Andrew Moore - a gentle introduction …
2013-1 Machine Learning Lecture 03 - Andrew Moore - a gentle introduction …Dongseo University
 
Complements and Conditional Probability, and Bayes' Theorem
 Complements and Conditional Probability, and Bayes' Theorem Complements and Conditional Probability, and Bayes' Theorem
Complements and Conditional Probability, and Bayes' TheoremLong Beach City College
 
probability_statistics_presentation.pptx
probability_statistics_presentation.pptxprobability_statistics_presentation.pptx
probability_statistics_presentation.pptxvietnam5hayday
 
1615 probability-notation for joint probabilities
1615 probability-notation for joint probabilities1615 probability-notation for joint probabilities
1615 probability-notation for joint probabilitiesDr Fereidoun Dejahang
 
Probability basics and bayes' theorem
Probability basics and bayes' theoremProbability basics and bayes' theorem
Probability basics and bayes' theoremBalaji P
 
What are the chances? - Probability
What are the chances? - ProbabilityWhat are the chances? - Probability
What are the chances? - Probabilitymscartersmaths
 
2.statistical DEcision makig.pptx
2.statistical DEcision makig.pptx2.statistical DEcision makig.pptx
2.statistical DEcision makig.pptxImpanaR2
 
Probability&Bayes theorem
Probability&Bayes theoremProbability&Bayes theorem
Probability&Bayes theoremimran iqbal
 
Statistical Analysis with R -II
Statistical Analysis with R -IIStatistical Analysis with R -II
Statistical Analysis with R -IIAkhila Prabhakaran
 
Complements conditional probability bayes theorem
Complements  conditional probability bayes theorem  Complements  conditional probability bayes theorem
Complements conditional probability bayes theorem Long Beach City College
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data AnalyticsSSaudia
 
UNIT-II-Probability-ConditionalProbability-BayesTherom.pptx
UNIT-II-Probability-ConditionalProbability-BayesTherom.pptxUNIT-II-Probability-ConditionalProbability-BayesTherom.pptx
UNIT-II-Probability-ConditionalProbability-BayesTherom.pptxChagantiSahith
 
1 Probability Please read sections 3.1 – 3.3 in your .docx
 1 Probability   Please read sections 3.1 – 3.3 in your .docx 1 Probability   Please read sections 3.1 – 3.3 in your .docx
1 Probability Please read sections 3.1 – 3.3 in your .docxaryan532920
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 

Similar to NAIVE BAYES CLASSIFIER (20)

Acem bayes classifier
Acem bayes classifierAcem bayes classifier
Acem bayes classifier
 
2013-1 Machine Learning Lecture 03 - Andrew Moore - a gentle introduction …
2013-1 Machine Learning Lecture 03 - Andrew Moore - a gentle introduction …2013-1 Machine Learning Lecture 03 - Andrew Moore - a gentle introduction …
2013-1 Machine Learning Lecture 03 - Andrew Moore - a gentle introduction …
 
Complements and Conditional Probability, and Bayes' Theorem
 Complements and Conditional Probability, and Bayes' Theorem Complements and Conditional Probability, and Bayes' Theorem
Complements and Conditional Probability, and Bayes' Theorem
 
probability_statistics_presentation.pptx
probability_statistics_presentation.pptxprobability_statistics_presentation.pptx
probability_statistics_presentation.pptx
 
Bayes Theorem
Bayes TheoremBayes Theorem
Bayes Theorem
 
1615 probability-notation for joint probabilities
1615 probability-notation for joint probabilities1615 probability-notation for joint probabilities
1615 probability-notation for joint probabilities
 
Probability basics and bayes' theorem
Probability basics and bayes' theoremProbability basics and bayes' theorem
Probability basics and bayes' theorem
 
What are the chances? - Probability
What are the chances? - ProbabilityWhat are the chances? - Probability
What are the chances? - Probability
 
2.statistical DEcision makig.pptx
2.statistical DEcision makig.pptx2.statistical DEcision makig.pptx
2.statistical DEcision makig.pptx
 
Probability&Bayes theorem
Probability&Bayes theoremProbability&Bayes theorem
Probability&Bayes theorem
 
Statistical Analysis with R -II
Statistical Analysis with R -IIStatistical Analysis with R -II
Statistical Analysis with R -II
 
Complements conditional probability bayes theorem
Complements  conditional probability bayes theorem  Complements  conditional probability bayes theorem
Complements conditional probability bayes theorem
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data Analytics
 
QT1 - 04 - Probability
QT1 - 04 - ProbabilityQT1 - 04 - Probability
QT1 - 04 - Probability
 
UNIT-II-Probability-ConditionalProbability-BayesTherom.pptx
UNIT-II-Probability-ConditionalProbability-BayesTherom.pptxUNIT-II-Probability-ConditionalProbability-BayesTherom.pptx
UNIT-II-Probability-ConditionalProbability-BayesTherom.pptx
 
1 Probability Please read sections 3.1 – 3.3 in your .docx
 1 Probability   Please read sections 3.1 – 3.3 in your .docx 1 Probability   Please read sections 3.1 – 3.3 in your .docx
1 Probability Please read sections 3.1 – 3.3 in your .docx
 
Lecture3
Lecture3Lecture3
Lecture3
 
Probability.pptx
Probability.pptxProbability.pptx
Probability.pptx
 
Laws of probability
Laws of probabilityLaws of probability
Laws of probability
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 

More from Knoldus Inc.

Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingKnoldus Inc.
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionKnoldus Inc.
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxKnoldus Inc.
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptxKnoldus Inc.
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfKnoldus Inc.
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxKnoldus Inc.
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingKnoldus Inc.
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesKnoldus Inc.
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxKnoldus Inc.
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxKnoldus Inc.
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxKnoldus Inc.
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxKnoldus Inc.
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxKnoldus Inc.
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationKnoldus Inc.
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationKnoldus Inc.
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIsKnoldus Inc.
 
Introduction To Rust part II Presentation
Introduction To Rust part II PresentationIntroduction To Rust part II Presentation
Introduction To Rust part II PresentationKnoldus Inc.
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Configuring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAConfiguring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAKnoldus Inc.
 
Advanced Python (with dependency injection and hydra configuration packages)
Advanced Python (with dependency injection and hydra configuration packages)Advanced Python (with dependency injection and hydra configuration packages)
Advanced Python (with dependency injection and hydra configuration packages)Knoldus Inc.
 

More from Knoldus Inc. (20)

Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptx
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdf
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptx
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable Testing
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose Kubernetes
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptx
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptx
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptx
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptx
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptx
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake Presentation
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics Presentation
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIs
 
Introduction To Rust part II Presentation
Introduction To Rust part II PresentationIntroduction To Rust part II Presentation
Introduction To Rust part II Presentation
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Configuring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAConfiguring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRA
 
Advanced Python (with dependency injection and hydra configuration packages)
Advanced Python (with dependency injection and hydra configuration packages)Advanced Python (with dependency injection and hydra configuration packages)
Advanced Python (with dependency injection and hydra configuration packages)
 

Recently uploaded

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

NAIVE BAYES CLASSIFIER

  • 1. NAIVE BAYES CLASSIFIER Nitin Aggarwal Software Consultant Knoldus Software LLP
  • 2. Agenda ● What is Conditional Probability ? ● What is Bayes Theorem? ● What is NAIVE BAYES CLASSIFIER? ● Types of Naive Bayes Algorithm.
  • 3. Conditional Probability 1. In probability theory, conditional probability is a measure of the probability of an event given that another event has already occurred. 2. If the event of interest is A and the event B is assumed to have occurred, "the conditional probability of A given B", or "the probability of A under the condition B", is usually written as P(A|B), or sometimes PB(A).
  • 4. Examples Chances of cough The probability that any given person has a cough on any given day maybe only 5%. But if we know or assume that the person has a cold, then they are much more likely to be coughing. The conditional probability of coughing given that person have a cold might be a much higher 75%.
  • 5. Marbles in a Bag 2 blue and 3 red marbles are in a bag. What are the chances of getting a blue marble? ???
  • 6. Marbles in a Bag 2 blue and 3 red marbles are in a bag. What are the chances of getting a blue marble? Answer: - The chance is 2 in 5
  • 7. But after taking one out of these chances, situation may change! So the next time: 1. if we got a red marble before, then the chance of a blue marble next is 2 in 4 2. if we got a blue marble before, then the chance of a blue marble next is 1 in 4
  • 8. Likewise:- Drawing a second ace from a deck given we got the first ace Finding the probability of having a disease given you were tested positive Finding the probability of liking Harry Potter given we know the person likes fiction.
  • 9. Bayes Theorem 1. In probability theory and statistics, Bayes’ theorem (alternatively Bayes’ law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. 2. For example, if cancer is related to age, then, using Bayes’ theorem, a person’s age can be used to more accurately to assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age.
  • 10. The Formula for Bayes’ theorem where 1. P(H) is the probability of hypothesis H being true. This is known as the prior probability. 2. P(E) is the probability of the evidence(regardless of the hypothesis). 3. P(E|H) is the probability of the evidence given that hypothesis is true. 4. P(H|E) is the probability of the hypothesis given that the evidence is there.
  • 11. Examples Suppose there are three bowls B1, B2, B3 and bowl B1 has 2 red and 4 blue coins; bowl B2 has 1 red and 2 blue coins; bowl B3 contains 5 red and 4 blue coins.Suppose the probabilities for selecting the bowls is not the same but are:- ● P(B1) = 1/3 ● P(B2) = 1/6 ● P(B3) = 1/2 Now, let us compute, assuming that a red coin was drawn what will be the probability that it came from bowl B1.
  • 12. In mathematics teams, we need to find out P(B1|R) = ??? And according to Bayes’ theorem P(B1|R) = P(R|B1) * P(B1) / P(R) For that first, we need to calculate some probabilities which are:- ● Probability to select a red coin i.e P(R) ● Probability to select the bowl 1 (B1) i.e P(B1) which is already given 1/3 ● Probability to select a red coin from B1 i.e P(R|B1)
  • 13. P(R) = P(B1 R) + (B2 R) + P(B3 R)⋂ ⋂ ⋂ where ● P(B1 R) is probability to select bowl 1 and red coin⋂ ● P(B2 R) is probability to select bowl 2 and red coin⋂ ● P(B3 R) is probability to select bowl 3 and red coin⋂ = P(selecting B1) * P(Number of Red coins / total number of coins in B1 ) + P(selecting B2) * P(Number of Red coins in B2 / total number of coins in B2 ) + P(selecting B3) * P(Number of Red coins in B3/ total number of coins in B3 )
  • 14. = 1/3 * 2/6 + 1/6 * 1/3 + 1/2* 5/9 = 4/9 So P(R) = 4/9
  • 15. P(R|B1) The probability of selecting a red coin given that it will be drawn from B1 is 2/6 P(B1) was given i.e 1/3. By putting all the values in formula: P(B1|R) = (2/6 *1/3) / 4/9 = 2/8 = 0.25 So we can say that if a red coin was drawn that it will be 25% chances that it was drawn from bowl 1 i.e B1.
  • 16. NAIVE BAYES CLASSIFIER ● Naive Bayes is a kind of classifier which uses the Bayes Theorem. ● It predicts membership probabilities for each class such as the probability that given record or data point belongs to a particular class. ● The class with the highest probability is considered as the most likely class. This is also known as Maximum A Posteriori (MAP).
  • 17. MAP(H) = max( P(H|E) ) = max( (P(E|H)*P(H))/P(E)) = max(P(E|H)*P(H)) P(E) is evidence probability, and it is used to normalize the result. It remains same so, removing it won’t affect.
  • 18. Assumption Naive Bayes classifier assumes that all the features are unrelated to each other. Presence or absence of a feature does not influence the presence or absence of any other feature. “A fruit may be considered to be an apple if it is red, round, and about 4″ in diameter. Even if these features depend on each other or upon the existence of the other features, a naive Bayes classifier considers all of these properties to independently contribute to the probability that this fruit is an apple.”
  • 19. In real datasets, we test a hypothesis given multiple evidence(feature). So, calculations become complicated. To simplify the work, the feature independence approach is used to ‘uncouple’ multiple evidence and treat each as an independent one. P(H|Multiple Evidences) = P(E1| H)* P(E2|H) ……*P(En|H) * P(H) / P(Multiple Evidences)
  • 20. For understanding a theoretical concept, the best procedure is to try it on an example. Let’s consider a training dataset with 1500 records and 3 classes. We presume that there are no missing values in our data. We have We have 3 classes associated with Animal Types: ● Parrot, ● Dog, ● Fish.
  • 21. The Predictor features set consists of 4 features as ● Swim ● Wings ● Green Color ● Dangerous Teeth. Swim,Wings,Green Color, Dangerous Teeth. All the features are categorical variables with either of the 2 values: T(True) or F( False).
  • 22. The above table shows a frequency table of our data. In our training data:
  • 23. ● Parrots have 50(10%) value for Swim, i.e., 10% parrot can swim according to our data, 500 out of 500(100%) parrots have wings, 400 out of 500(80%) parrots are Green and 0(0%) parrots have Dangerous Teeth. ● Classes with Animal type Dogs shows that 450 out of 500(90%) can swim, 0(0%) dogs have wings, 0(0%) dogs are of Green color and 500 out of 500(100%) dogs have Dangerous Teeth. ● Classes with Animal type Fishes shows that 500 out of 500(100%) can swim, 0(0%) fishes have wings, 100(20%) fishes are of Green color and 50 out of 500(10%) Fishes have Dangerous Teeth.
  • 24. Now, it’s time to work on predict classes using the Naive Bayes model. We have taken 2 records that have values in their feature set, but the target variable needs to predicted.
  • 25. ● We have to predict animal type using the feature values. We have to predict whether the animal is a Dog, a Parrot or a Fish P(H|Multiple Evidences) = P(E1| H)* P(E2|H) ……*P(En|H) * P(H) / P(Multiple Evidences) Let’s consider the first record. The Evidence here is Swim & Green. The Hypothesis can be an animal type to be Dog, Parrot, Fish.
  • 26. For Hypothesis testing for the animal to be a Dog: P(Dog | Swim, Green) = P(Swim|Dog) * P(Green|Dog) * P(Dog) / P(Swim, Green) = 0.9 * 0 * 0.333 / P(Swim, Green) = 0
  • 27. For Hypothesis testing for the animal to be a Parrot: P(Parrot| Swim, Green) = P(Swim|Parrot) * P(Green|Parrot) * P(Parrot) / P(Swim, Green) = 0.1 * 0.80 * 0.333 / P(Swim, Green) = 0.0264/ P(Swim, Green)
  • 28. For Hypothesis testing for the animal to be a Fish: P(Fish| Swim, Green) = P(Swim|Fish) * P(Green|Fish) * P(Fish) / P(Swim, Green) = 1 * 0.2 * 0.333 / P(Swim, Green) = 0.0666/ P(Swim, Green)
  • 29. The denominator of all the above calculations is same i.e, P(Swim, Green). The value of P(Fish| Swim, Green) is greater that P(Parrot| Swim, Green). Using Naive Bayes, we can predict that the class of this record is Fish.
  • 30. Let’s consider the second record. The Evidence here is Swim, Green & Teeth. The Hypothesis can be an animal type to be Dog, Parrot, Fish. For Hypothesis testing for the animal to be a Dog: P(Dog | Swim, Green, Teeth) = P(Swim|Dog) * P(Green|Dog) * P(Teeth|Dog) * P(Dog) / P(Swim, Green, Teeth) = 0.9 * 0 * 1 * 0.333 / P(Swim, Green, Teeth) = 0
  • 31. For Hypothesis testing for the animal to be a Parrot: P(Parrot| Swim, Green, Teeth) = P(Swim|Parrot) * P(Green|Parrot)* P(Teeth| Parrot) * P(Parrot) / P(Swim, Green, Teeth) = 0.1 * 0.80 * 0 *0.333 / P(Swim, Green, Teeth) = 0
  • 32. For Hypothesis testing for the animal to be a Fish: P(Fish|Swim, Green, Teeth) = P(Swim|Fish) * P(Green|Fish) * P(Teeth|Fish) *P(Fish) / P(Swim, Green, Teeth) = 1 * 0.2 * 0.1 * 0.333 / P(Swim, Green, Teeth) = 0.00666 / P(Swim, Green, Teeth)
  • 33. The value of P(Fish| Swim, Green, Teeth) is the only positive value greater than 0. Using Naive Bayes, we can predict that the class of this record is Fish.
  • 34. Types of Naive Bayes Algorithm Gaussian: It is used in classification and it assumes that features follow a normal distribution. Bernoulli: The binomial model is useful if your feature vectors are binary (i.e. zeros and ones). One application would be text classification with ‘bag of words’ model where the 1s & 0s are “word occurs in the document” and “word does not occur in the document” respectively.
  • 35. MultiNomial Naive Bayes is preferred to use on data that is multinomially distributed. For example, let’s say, we have a text classification problem. Here we can consider bernoulli trials which is one step further and instead of “word occurring in the document”, we have “count how often word occurs in the document”, you can think of it as “number of times outcome number x_i is observed over the n trials”.