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

Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree LearningMilind Gokhale
 
Introduction to Machine Learning Classifiers
Introduction to Machine Learning ClassifiersIntroduction to Machine Learning Classifiers
Introduction to Machine Learning ClassifiersFunctional Imperative
 
Classification Based Machine Learning Algorithms
Classification Based Machine Learning AlgorithmsClassification Based Machine Learning Algorithms
Classification Based Machine Learning AlgorithmsMd. Main Uddin Rony
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data miningKamal Acharya
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning Mohammad Junaid Khan
 
MachineLearning.ppt
MachineLearning.pptMachineLearning.ppt
MachineLearning.pptbutest
 
Machine Learning with Decision trees
Machine Learning with Decision treesMachine Learning with Decision trees
Machine Learning with Decision treesKnoldus Inc.
 
Data preprocessing in Machine learning
Data preprocessing in Machine learning Data preprocessing in Machine learning
Data preprocessing in Machine learning pyingkodi maran
 
Feature selection
Feature selectionFeature selection
Feature selectionDong Guo
 
Ensemble learning
Ensemble learningEnsemble learning
Ensemble learningHaris Jamil
 
ADABoost classifier
ADABoost classifierADABoost classifier
ADABoost classifierSreerajVA
 
Classification and Regression
Classification and RegressionClassification and Regression
Classification and RegressionMegha Sharma
 
Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees Kush Kulshrestha
 
Bayes Classification
Bayes ClassificationBayes Classification
Bayes Classificationsathish sak
 
K-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierK-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierNeha Kulkarni
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine LearningKuppusamy P
 

What's hot (20)

Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree Learning
 
Introduction to Machine Learning Classifiers
Introduction to Machine Learning ClassifiersIntroduction to Machine Learning Classifiers
Introduction to Machine Learning Classifiers
 
Naive Bayes Presentation
Naive Bayes PresentationNaive Bayes Presentation
Naive Bayes Presentation
 
Classification Based Machine Learning Algorithms
Classification Based Machine Learning AlgorithmsClassification Based Machine Learning Algorithms
Classification Based Machine Learning Algorithms
 
Lecture10 - Naïve Bayes
Lecture10 - Naïve BayesLecture10 - Naïve Bayes
Lecture10 - Naïve Bayes
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data mining
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning
 
MachineLearning.ppt
MachineLearning.pptMachineLearning.ppt
MachineLearning.ppt
 
Machine Learning with Decision trees
Machine Learning with Decision treesMachine Learning with Decision trees
Machine Learning with Decision trees
 
Data preprocessing in Machine learning
Data preprocessing in Machine learning Data preprocessing in Machine learning
Data preprocessing in Machine learning
 
Feature selection
Feature selectionFeature selection
Feature selection
 
K Nearest Neighbors
K Nearest NeighborsK Nearest Neighbors
K Nearest Neighbors
 
Ensemble learning
Ensemble learningEnsemble learning
Ensemble learning
 
ADABoost classifier
ADABoost classifierADABoost classifier
ADABoost classifier
 
Classification and Regression
Classification and RegressionClassification and Regression
Classification and Regression
 
Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees Machine Learning Algorithm - Decision Trees
Machine Learning Algorithm - Decision Trees
 
Bayes Classification
Bayes ClassificationBayes Classification
Bayes Classification
 
Confusion Matrix Explained
Confusion Matrix ExplainedConfusion Matrix Explained
Confusion Matrix Explained
 
K-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierK-Nearest Neighbor Classifier
K-Nearest Neighbor Classifier
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression 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.

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.
 
Azure Databricks (For Data Analytics).pptx
Azure Databricks (For Data Analytics).pptxAzure Databricks (For Data Analytics).pptx
Azure Databricks (For Data Analytics).pptxKnoldus Inc.
 
The Power of Dependency Injection with Dagger 2 and Kotlin
The Power of Dependency Injection with Dagger 2 and KotlinThe Power of Dependency Injection with Dagger 2 and Kotlin
The Power of Dependency Injection with Dagger 2 and KotlinKnoldus Inc.
 
Data Engineering with Databricks Presentation
Data Engineering with Databricks PresentationData Engineering with Databricks Presentation
Data Engineering with Databricks PresentationKnoldus Inc.
 
Databricks for MLOps Presentation (AI/ML)
Databricks for MLOps Presentation (AI/ML)Databricks for MLOps Presentation (AI/ML)
Databricks for MLOps Presentation (AI/ML)Knoldus Inc.
 
NoOps - (Automate Ops) Presentation.pptx
NoOps - (Automate Ops) Presentation.pptxNoOps - (Automate Ops) Presentation.pptx
NoOps - (Automate Ops) Presentation.pptxKnoldus Inc.
 
Mastering Distributed Performance Testing
Mastering Distributed Performance TestingMastering Distributed Performance Testing
Mastering Distributed Performance TestingKnoldus Inc.
 
MLops on Vertex AI Presentation (AI/ML).pptx
MLops on Vertex AI Presentation (AI/ML).pptxMLops on Vertex AI Presentation (AI/ML).pptx
MLops on Vertex AI Presentation (AI/ML).pptxKnoldus Inc.
 
Introduction to Ansible Tower Presentation
Introduction to Ansible Tower PresentationIntroduction to Ansible Tower Presentation
Introduction to Ansible Tower PresentationKnoldus Inc.
 
CQRS with dot net services presentation.
CQRS with dot net services presentation.CQRS with dot net services presentation.
CQRS with dot net services presentation.Knoldus Inc.
 

More from Knoldus Inc. (20)

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)
 
Azure Databricks (For Data Analytics).pptx
Azure Databricks (For Data Analytics).pptxAzure Databricks (For Data Analytics).pptx
Azure Databricks (For Data Analytics).pptx
 
The Power of Dependency Injection with Dagger 2 and Kotlin
The Power of Dependency Injection with Dagger 2 and KotlinThe Power of Dependency Injection with Dagger 2 and Kotlin
The Power of Dependency Injection with Dagger 2 and Kotlin
 
Data Engineering with Databricks Presentation
Data Engineering with Databricks PresentationData Engineering with Databricks Presentation
Data Engineering with Databricks Presentation
 
Databricks for MLOps Presentation (AI/ML)
Databricks for MLOps Presentation (AI/ML)Databricks for MLOps Presentation (AI/ML)
Databricks for MLOps Presentation (AI/ML)
 
NoOps - (Automate Ops) Presentation.pptx
NoOps - (Automate Ops) Presentation.pptxNoOps - (Automate Ops) Presentation.pptx
NoOps - (Automate Ops) Presentation.pptx
 
Mastering Distributed Performance Testing
Mastering Distributed Performance TestingMastering Distributed Performance Testing
Mastering Distributed Performance Testing
 
MLops on Vertex AI Presentation (AI/ML).pptx
MLops on Vertex AI Presentation (AI/ML).pptxMLops on Vertex AI Presentation (AI/ML).pptx
MLops on Vertex AI Presentation (AI/ML).pptx
 
Introduction to Ansible Tower Presentation
Introduction to Ansible Tower PresentationIntroduction to Ansible Tower Presentation
Introduction to Ansible Tower Presentation
 
CQRS with dot net services presentation.
CQRS with dot net services presentation.CQRS with dot net services presentation.
CQRS with dot net services presentation.
 

Recently uploaded

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 

Recently uploaded (20)

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 

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”.