SlideShare una empresa de Scribd logo
1 de 3
Naïve Bayes Classifier
By Occam’s razor or the law of parsimony, the best algorithms are the simplest. The field of
data science has progressed from simple linear regression models to complex ensembling
techniques but the most preferred models are still the simplest and most interpretable. Among
them are regression, logistic, trees and naive Bayes techniques. Naive Bayes algorithm, in
particular is a logic-based technique which is simple yet so powerful that it is often known to
outperform complex algorithms for very large datasets. Naive Bayes is a common technique
used in the field of medical science and is especially used for cancer detection. This note
explains the underlying logic behind naive Bayes algorithm.
Bayes theorem
We calculate probability as the proportion of cases where an event happens and call it the
probability of the event. Just as there is probability for a single event, we have probability of a
group of events as the proportion of cases where the group of events occur together. Another
concept in probability is calculating the occurrence of events in a particular sequence, that is,
if it is known that something has already happened, what will be the probability that another
event happens after that. By logic, one can understand that we are narrowing down our scope
to only the case when that something has already happened and then calculating the proportion
of cases where our second event occurs. To represent it mathematically, If A is the first event
and B is the second event, then P(B/A) is our desired probability which is obtained by the
simplest expression of Bayes theorem.
P(B/A) = P(B) * P(A/B) / P(A)
This is the foundation pillar for naive Bayes algorithm. If the two probabilities, P(B) and
P(B/A) are same, then it means that the occurrence of event A had no effect on event B and the
events are known as independent events. If the conditional probability becomes zero, then it
means the occurrence of event A implies that event B cannot occur. If the reverse is also true,
then the events are known as mutually exclusive events and the occurrence of only one of the
events at a time is possible. All other cases are classified as dependent events where the
conditional probability can be either lower or higher than the original. In real life, every coin
toss is independent of all other coin tosses made previously and thus coin tosses are
independent. The outcome of a single coin toss is composed of mutually exclusive events. We
cannot have a head and the tail at the same time. When we consider runs of multiple coin tosses,
we are talking about dependent events. For a combination of three-coin tosses in sequence, the
final outcome is dependent on the first, second as well as the third coin toss.
It is easy to calculate the probability of a single event. It equates to the number of cases when
the event occurs divided by the total number of possible cases. For instance, the probability of
a 6 in a single six-faced die roll is ⅙ if all the sides have equal chance of coming. However,
one needs to be careful when calculating probabilities of two or more events. Simply knowing
the probability of each event separately is not enough to calculate the probability of multiple
events happening. If we additionally know that the events are independent, then the probability
of them occurring together is the product of individual probabilities. We denote this
mathematically as follows:
P(A and B)=P(A)*P(B) – for independent events
P(A and B)=P(A)*P(B|A) – for dependent events
If the events are mutually exclusive, we know that only one of the events can occur at a time.
So, the probability of the two events occurring together is zero. Put in a more formal form, we
have,
P(A or B)=P(A) + P(B) – for mutually exclusive events
P(A or B)=P(A) + P(B) - P(A and B) – for events which are not mutually exclusive
Naive Bayes Algorithm
The reason that Naive Bayes algorithm is called naive is not because it is simple. It is because
the algorithm makes a very strong assumption about the data having features independent of
each other while in reality, they may be dependent in some way. In other words, it assumes that
the presence of one feature in a class is completely unrelated to the presence of all other
features. If this assumption of independence holds, Naive Bayes performs extremely well and
often better than other models. This assumption makes the Bayes algorithm naïve which
implies that given n different attribute values (Xi, i=1,…,n) the joint probability (likelihood)
can be written as,
𝑃(𝑋 , … , 𝑋 /𝑌) = 𝑃(𝑋 /𝑌)
Here, X represents the attributes or features, and Y is the response variable. Now, P(X|Y)
becomes equal to the products of probability of each attribute X given Y.
What we are interested in, is finding the posterior probability or P(Y|X) which is,
𝑃(𝑌/𝑋 , … , 𝑋 ) = 𝑃(𝑌) 𝑃(𝑋 /𝑌) / 𝑃(𝑋 )
As the denominator remains constant for a given input, we can remove that and express the
equation as
𝑃(𝑌/𝑋 , … , 𝑋 )𝛼 𝑃(𝑌) 𝑃(𝑋 /𝑌)
Now, we need to create a classifier model. For this, we find the probability of a given set of
inputs for all possible values of the class variable Y and pick up the output with maximum
probability. This can be expressed as
𝑌 = 𝑎𝑟𝑔𝑢𝑚𝑎𝑥 𝑃(𝑌) 𝑃(𝑋 /𝑌)
For multiple values of Y, we will need to calculate this expression for each of them. Given a
new instance of X, we need to calculate the probability that Y will take on any given value,
given the observed attribute values of new X and the distributions P(Y) and P(X|Y) estimated
from the training data. Based on the different values we attain for P(Y|X), we simply take the
most probable or maximum of these values.
If we assume that the response variable is uniformly distributed, that is it is equally likely to
get any response, then we can further simplify the algorithm. With this assumption the priori
or P(Y) becomes a constant value, which is (1/number of categories of the response). As the
prior and the evidence are now independent of the response variable, these can be removed
from the equation. Therefore, the maximizing the posteriori will be reduced to maximizing the
likelihood problem.
Naive Bayes can also be used with continuous features but is more suited to categorical
variables. If all the input features are categorical, Naive Bayes is recommended. However, in
the case of numeric features, it makes another strong assumption which is that the numerical
variable is normally distributed.
Sometimes, a smoothing procedure is implemented in Naïve Bayes to avoid zero probabilities
for certain levels of the response variable. This is called Laplace/Laplacian correction achieved
through adding a pseudo count of one or higher to both numerator and denominator counts
while working out the conditional probabilities 𝑃(𝑋 /𝑌).
-- Jayaraman

Más contenido relacionado

Similar a Naive bayes

Probabilistic decision making
Probabilistic decision makingProbabilistic decision making
Probabilistic decision makingshri1984
 
Different types of distributions
Different types of distributionsDifferent types of distributions
Different types of distributionsRajaKrishnan M
 
Ppt unit-05-mbf103
Ppt unit-05-mbf103Ppt unit-05-mbf103
Ppt unit-05-mbf103Vibha Nayak
 
Introduction to Probability and Bayes' Theorom
Introduction to Probability and Bayes' TheoromIntroduction to Probability and Bayes' Theorom
Introduction to Probability and Bayes' TheoromYugal Gupta
 
Probability.pptx
Probability.pptxProbability.pptx
Probability.pptxmangalyap23
 
Basic probability theory and statistics
Basic probability theory and statisticsBasic probability theory and statistics
Basic probability theory and statisticsLearnbay Datascience
 
Probability decision making
Probability decision makingProbability decision making
Probability decision makingChristian Tobing
 
01_Module_1-ProbabilityTheory.pptx
01_Module_1-ProbabilityTheory.pptx01_Module_1-ProbabilityTheory.pptx
01_Module_1-ProbabilityTheory.pptxSauravDash10
 
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptxCHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptxanshujain54751
 
Chapter 1 - Probability Distributions.pdf
Chapter 1 - Probability Distributions.pdfChapter 1 - Probability Distributions.pdf
Chapter 1 - Probability Distributions.pdfMayurMandhub
 
Probability Theory
Probability TheoryProbability Theory
Probability TheoryParul Singh
 
PROBABILITY AND IT'S TYPES WITH RULES
PROBABILITY AND IT'S TYPES WITH RULESPROBABILITY AND IT'S TYPES WITH RULES
PROBABILITY AND IT'S TYPES WITH RULESBhargavi Bhanu
 
Appendix 2 Probability And Statistics
Appendix 2  Probability And StatisticsAppendix 2  Probability And Statistics
Appendix 2 Probability And StatisticsSarah Morrow
 
introduction to Probability theory
introduction to Probability theoryintroduction to Probability theory
introduction to Probability theoryRachna Gupta
 
MSL 5080, Methods of Analysis for Business Operations 1 .docx
MSL 5080, Methods of Analysis for Business Operations 1 .docxMSL 5080, Methods of Analysis for Business Operations 1 .docx
MSL 5080, Methods of Analysis for Business Operations 1 .docxAASTHA76
 
Mathematics for Language Technology: Introduction to Probability Theory
Mathematics for Language Technology: Introduction to Probability TheoryMathematics for Language Technology: Introduction to Probability Theory
Mathematics for Language Technology: Introduction to Probability TheoryMarina Santini
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data AnalyticsSSaudia
 

Similar a Naive bayes (20)

Probabilistic decision making
Probabilistic decision makingProbabilistic decision making
Probabilistic decision making
 
Different types of distributions
Different types of distributionsDifferent types of distributions
Different types of distributions
 
Ppt unit-05-mbf103
Ppt unit-05-mbf103Ppt unit-05-mbf103
Ppt unit-05-mbf103
 
Introduction to Probability and Bayes' Theorom
Introduction to Probability and Bayes' TheoromIntroduction to Probability and Bayes' Theorom
Introduction to Probability and Bayes' Theorom
 
Probablity & queueing theory basic terminologies & applications
Probablity & queueing theory basic terminologies & applicationsProbablity & queueing theory basic terminologies & applications
Probablity & queueing theory basic terminologies & applications
 
Probability.pptx
Probability.pptxProbability.pptx
Probability.pptx
 
Basic probability theory and statistics
Basic probability theory and statisticsBasic probability theory and statistics
Basic probability theory and statistics
 
Probability decision making
Probability decision makingProbability decision making
Probability decision making
 
01_Module_1-ProbabilityTheory.pptx
01_Module_1-ProbabilityTheory.pptx01_Module_1-ProbabilityTheory.pptx
01_Module_1-ProbabilityTheory.pptx
 
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptxCHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
 
Naive Bayes.pptx
Naive Bayes.pptxNaive Bayes.pptx
Naive Bayes.pptx
 
Chapter 1 - Probability Distributions.pdf
Chapter 1 - Probability Distributions.pdfChapter 1 - Probability Distributions.pdf
Chapter 1 - Probability Distributions.pdf
 
Probability Theory
Probability TheoryProbability Theory
Probability Theory
 
PROBABILITY AND IT'S TYPES WITH RULES
PROBABILITY AND IT'S TYPES WITH RULESPROBABILITY AND IT'S TYPES WITH RULES
PROBABILITY AND IT'S TYPES WITH RULES
 
Machine learning session2
Machine learning   session2Machine learning   session2
Machine learning session2
 
Appendix 2 Probability And Statistics
Appendix 2  Probability And StatisticsAppendix 2  Probability And Statistics
Appendix 2 Probability And Statistics
 
introduction to Probability theory
introduction to Probability theoryintroduction to Probability theory
introduction to Probability theory
 
MSL 5080, Methods of Analysis for Business Operations 1 .docx
MSL 5080, Methods of Analysis for Business Operations 1 .docxMSL 5080, Methods of Analysis for Business Operations 1 .docx
MSL 5080, Methods of Analysis for Business Operations 1 .docx
 
Mathematics for Language Technology: Introduction to Probability Theory
Mathematics for Language Technology: Introduction to Probability TheoryMathematics for Language Technology: Introduction to Probability Theory
Mathematics for Language Technology: Introduction to Probability Theory
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data Analytics
 

Más de Ayurdata

Statistical distributions
Statistical distributionsStatistical distributions
Statistical distributionsAyurdata
 
Health Behaviour: An Ayurveda Perspective
Health Behaviour: An Ayurveda PerspectiveHealth Behaviour: An Ayurveda Perspective
Health Behaviour: An Ayurveda PerspectiveAyurdata
 
Ayur data
Ayur data Ayur data
Ayur data Ayurdata
 
Stat Methods in ayurveda
Stat Methods in ayurvedaStat Methods in ayurveda
Stat Methods in ayurvedaAyurdata
 
Ayurveda colleges and courses
Ayurveda colleges and coursesAyurveda colleges and courses
Ayurveda colleges and coursesAyurdata
 
AyurData Ayurveda Webinar
AyurData Ayurveda WebinarAyurData Ayurveda Webinar
AyurData Ayurveda WebinarAyurdata
 
Advanced Statistical Manual for Ayurveda Research
Advanced Statistical Manual for Ayurveda ResearchAdvanced Statistical Manual for Ayurveda Research
Advanced Statistical Manual for Ayurveda ResearchAyurdata
 
Advanced manual part 4
Advanced manual part 4Advanced manual part 4
Advanced manual part 4Ayurdata
 
Investigation modes in ayurveda
Investigation modes in ayurvedaInvestigation modes in ayurveda
Investigation modes in ayurvedaAyurdata
 
Advanced Statistical Manual Part III
Advanced Statistical Manual Part IIIAdvanced Statistical Manual Part III
Advanced Statistical Manual Part IIIAyurdata
 
Advanced statistical manual part ii
Advanced statistical manual part iiAdvanced statistical manual part ii
Advanced statistical manual part iiAyurdata
 
Advanced statistical manual part i
Advanced statistical manual part iAdvanced statistical manual part i
Advanced statistical manual part iAyurdata
 
Advanced statistical manual for ayurveda research sample
Advanced statistical manual for ayurveda research sampleAdvanced statistical manual for ayurveda research sample
Advanced statistical manual for ayurveda research sampleAyurdata
 
Ayurveda vs allopathy
Ayurveda vs allopathyAyurveda vs allopathy
Ayurveda vs allopathyAyurdata
 
Meta-Analysis in Ayurveda
Meta-Analysis in AyurvedaMeta-Analysis in Ayurveda
Meta-Analysis in AyurvedaAyurdata
 
A manual on statistical analysis in ayurveda research
A manual on statistical analysis in ayurveda researchA manual on statistical analysis in ayurveda research
A manual on statistical analysis in ayurveda researchAyurdata
 
Ich sample size
Ich sample sizeIch sample size
Ich sample sizeAyurdata
 
Classifiers
ClassifiersClassifiers
ClassifiersAyurdata
 
Logistic regression
Logistic regressionLogistic regression
Logistic regressionAyurdata
 

Más de Ayurdata (20)

Statistical distributions
Statistical distributionsStatistical distributions
Statistical distributions
 
BMI
BMIBMI
BMI
 
Health Behaviour: An Ayurveda Perspective
Health Behaviour: An Ayurveda PerspectiveHealth Behaviour: An Ayurveda Perspective
Health Behaviour: An Ayurveda Perspective
 
Ayur data
Ayur data Ayur data
Ayur data
 
Stat Methods in ayurveda
Stat Methods in ayurvedaStat Methods in ayurveda
Stat Methods in ayurveda
 
Ayurveda colleges and courses
Ayurveda colleges and coursesAyurveda colleges and courses
Ayurveda colleges and courses
 
AyurData Ayurveda Webinar
AyurData Ayurveda WebinarAyurData Ayurveda Webinar
AyurData Ayurveda Webinar
 
Advanced Statistical Manual for Ayurveda Research
Advanced Statistical Manual for Ayurveda ResearchAdvanced Statistical Manual for Ayurveda Research
Advanced Statistical Manual for Ayurveda Research
 
Advanced manual part 4
Advanced manual part 4Advanced manual part 4
Advanced manual part 4
 
Investigation modes in ayurveda
Investigation modes in ayurvedaInvestigation modes in ayurveda
Investigation modes in ayurveda
 
Advanced Statistical Manual Part III
Advanced Statistical Manual Part IIIAdvanced Statistical Manual Part III
Advanced Statistical Manual Part III
 
Advanced statistical manual part ii
Advanced statistical manual part iiAdvanced statistical manual part ii
Advanced statistical manual part ii
 
Advanced statistical manual part i
Advanced statistical manual part iAdvanced statistical manual part i
Advanced statistical manual part i
 
Advanced statistical manual for ayurveda research sample
Advanced statistical manual for ayurveda research sampleAdvanced statistical manual for ayurveda research sample
Advanced statistical manual for ayurveda research sample
 
Ayurveda vs allopathy
Ayurveda vs allopathyAyurveda vs allopathy
Ayurveda vs allopathy
 
Meta-Analysis in Ayurveda
Meta-Analysis in AyurvedaMeta-Analysis in Ayurveda
Meta-Analysis in Ayurveda
 
A manual on statistical analysis in ayurveda research
A manual on statistical analysis in ayurveda researchA manual on statistical analysis in ayurveda research
A manual on statistical analysis in ayurveda research
 
Ich sample size
Ich sample sizeIch sample size
Ich sample size
 
Classifiers
ClassifiersClassifiers
Classifiers
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 

Último

Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...gragchanchal546
 
20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdfkhraisr
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制vexqp
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.pptibrahimabdi22
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...nirzagarg
 
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...kumargunjan9515
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraGovindSinghDasila
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...nirzagarg
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...Bertram Ludäscher
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...HyderabadDolls
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...gajnagarg
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxchadhar227
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...HyderabadDolls
 
Computer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdfComputer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdfSayantanBiswas37
 
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...nirzagarg
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...nirzagarg
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...HyderabadDolls
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...SOFTTECHHUB
 

Último (20)

Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
 
20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
 
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - Almora
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
 
Computer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdfComputer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdf
 
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
 

Naive bayes

  • 1. Naïve Bayes Classifier By Occam’s razor or the law of parsimony, the best algorithms are the simplest. The field of data science has progressed from simple linear regression models to complex ensembling techniques but the most preferred models are still the simplest and most interpretable. Among them are regression, logistic, trees and naive Bayes techniques. Naive Bayes algorithm, in particular is a logic-based technique which is simple yet so powerful that it is often known to outperform complex algorithms for very large datasets. Naive Bayes is a common technique used in the field of medical science and is especially used for cancer detection. This note explains the underlying logic behind naive Bayes algorithm. Bayes theorem We calculate probability as the proportion of cases where an event happens and call it the probability of the event. Just as there is probability for a single event, we have probability of a group of events as the proportion of cases where the group of events occur together. Another concept in probability is calculating the occurrence of events in a particular sequence, that is, if it is known that something has already happened, what will be the probability that another event happens after that. By logic, one can understand that we are narrowing down our scope to only the case when that something has already happened and then calculating the proportion of cases where our second event occurs. To represent it mathematically, If A is the first event and B is the second event, then P(B/A) is our desired probability which is obtained by the simplest expression of Bayes theorem. P(B/A) = P(B) * P(A/B) / P(A) This is the foundation pillar for naive Bayes algorithm. If the two probabilities, P(B) and P(B/A) are same, then it means that the occurrence of event A had no effect on event B and the events are known as independent events. If the conditional probability becomes zero, then it means the occurrence of event A implies that event B cannot occur. If the reverse is also true, then the events are known as mutually exclusive events and the occurrence of only one of the events at a time is possible. All other cases are classified as dependent events where the conditional probability can be either lower or higher than the original. In real life, every coin toss is independent of all other coin tosses made previously and thus coin tosses are independent. The outcome of a single coin toss is composed of mutually exclusive events. We cannot have a head and the tail at the same time. When we consider runs of multiple coin tosses, we are talking about dependent events. For a combination of three-coin tosses in sequence, the final outcome is dependent on the first, second as well as the third coin toss. It is easy to calculate the probability of a single event. It equates to the number of cases when the event occurs divided by the total number of possible cases. For instance, the probability of a 6 in a single six-faced die roll is ⅙ if all the sides have equal chance of coming. However, one needs to be careful when calculating probabilities of two or more events. Simply knowing the probability of each event separately is not enough to calculate the probability of multiple events happening. If we additionally know that the events are independent, then the probability of them occurring together is the product of individual probabilities. We denote this mathematically as follows: P(A and B)=P(A)*P(B) – for independent events P(A and B)=P(A)*P(B|A) – for dependent events
  • 2. If the events are mutually exclusive, we know that only one of the events can occur at a time. So, the probability of the two events occurring together is zero. Put in a more formal form, we have, P(A or B)=P(A) + P(B) – for mutually exclusive events P(A or B)=P(A) + P(B) - P(A and B) – for events which are not mutually exclusive Naive Bayes Algorithm The reason that Naive Bayes algorithm is called naive is not because it is simple. It is because the algorithm makes a very strong assumption about the data having features independent of each other while in reality, they may be dependent in some way. In other words, it assumes that the presence of one feature in a class is completely unrelated to the presence of all other features. If this assumption of independence holds, Naive Bayes performs extremely well and often better than other models. This assumption makes the Bayes algorithm naïve which implies that given n different attribute values (Xi, i=1,…,n) the joint probability (likelihood) can be written as, 𝑃(𝑋 , … , 𝑋 /𝑌) = 𝑃(𝑋 /𝑌) Here, X represents the attributes or features, and Y is the response variable. Now, P(X|Y) becomes equal to the products of probability of each attribute X given Y. What we are interested in, is finding the posterior probability or P(Y|X) which is, 𝑃(𝑌/𝑋 , … , 𝑋 ) = 𝑃(𝑌) 𝑃(𝑋 /𝑌) / 𝑃(𝑋 ) As the denominator remains constant for a given input, we can remove that and express the equation as 𝑃(𝑌/𝑋 , … , 𝑋 )𝛼 𝑃(𝑌) 𝑃(𝑋 /𝑌) Now, we need to create a classifier model. For this, we find the probability of a given set of inputs for all possible values of the class variable Y and pick up the output with maximum probability. This can be expressed as 𝑌 = 𝑎𝑟𝑔𝑢𝑚𝑎𝑥 𝑃(𝑌) 𝑃(𝑋 /𝑌) For multiple values of Y, we will need to calculate this expression for each of them. Given a new instance of X, we need to calculate the probability that Y will take on any given value, given the observed attribute values of new X and the distributions P(Y) and P(X|Y) estimated from the training data. Based on the different values we attain for P(Y|X), we simply take the most probable or maximum of these values. If we assume that the response variable is uniformly distributed, that is it is equally likely to get any response, then we can further simplify the algorithm. With this assumption the priori or P(Y) becomes a constant value, which is (1/number of categories of the response). As the prior and the evidence are now independent of the response variable, these can be removed from the equation. Therefore, the maximizing the posteriori will be reduced to maximizing the likelihood problem.
  • 3. Naive Bayes can also be used with continuous features but is more suited to categorical variables. If all the input features are categorical, Naive Bayes is recommended. However, in the case of numeric features, it makes another strong assumption which is that the numerical variable is normally distributed. Sometimes, a smoothing procedure is implemented in Naïve Bayes to avoid zero probabilities for certain levels of the response variable. This is called Laplace/Laplacian correction achieved through adding a pseudo count of one or higher to both numerator and denominator counts while working out the conditional probabilities 𝑃(𝑋 /𝑌). -- Jayaraman