SlideShare a Scribd company logo
1 of 16
Naïve bayes
Lecture note
AASTU
2/3/2024
Outline
• Background
• Probability Basics
• Probabilistic Classification
• Naïve Bayes
• Example: Play Tennis
• Relevant Issues
• Conclusions
2/3/2024
A Naive Bayes classifier
• is a probabilistic machine learning model that’s used for
classification task.
• The crux of the classifier is based on the Bayes theorem.
• Using Bayes theorem, we can find the probability
of A happening, given that B has occurred.
• Here, B is the evidence and A is the hypothesis.
• The assumption made here is that the predictors/features are
independent.
2/3/2024
Probability Basics
• Prior, conditional and joint probability
– Prior probability:
– Conditional probability:
– Joint probability:
– Relationship:
– Independence:
• Bayesian Rule
𝑃(𝑋)
𝑃(𝑋1|𝑋2), 𝑃(𝑋2|𝑋1)
𝐗 = 𝑋1, 𝑋2 ⇒ 𝑃(𝐗) = 𝑃(𝑋1 , 𝑋2)
𝑃(𝑋1 , 𝑋2) = 𝑃(𝑋2|𝑋1)𝑃(𝑋1) = 𝑃(𝑋1|𝑋2)𝑃(𝑋2)
𝑃 𝑋2 𝑋1 = 𝑃 𝑋2 , 𝑃 𝑋1 𝑋2 = 𝑃 𝑋1 ,
=> 𝑃(𝑋1 , 𝑋2) = 𝑃(𝑋1)𝑃(𝑋2)
𝑃(𝐶|𝐗) =
𝑃(𝐗|𝐶)𝑃(𝐶)
𝑃(𝐗)
𝑃𝑜𝑠𝑡𝑒𝑟𝑖𝑜𝑟 =
𝐿𝑖𝑘𝑒𝑙𝑖ℎ𝑜𝑜𝑑 × 𝑃𝑟𝑖𝑜𝑟
𝐸𝑣𝑖𝑑𝑒𝑛𝑐𝑒
2/3/2024
Example by Dieter Fox
taken
2/3/2024
2/3/2024
2/3/2024
Probabilistic Classification
• Establishing a probabilistic model for classification
– Discriminative model:
– Generative model:
• MAP classification rule
– MAP: Maximum A Posterior
– Assign x to c* if
• Generative classification with the MAP rule
– Apply Bayesian rule to convert:
𝑃(𝐶|𝐗) 𝐶 = 𝑐1,⋅⋅⋅, 𝑐𝐿, 𝐗 = (𝑋1,⋅⋅⋅, 𝑋𝑛)
𝑃(𝐗|𝐶) 𝐶 = 𝑐1,⋅⋅⋅, 𝑐𝐿, 𝐗 = (𝑋1,⋅⋅⋅, 𝑋𝑛)
𝑃(𝐶 = 𝑐∗
|𝐗 = 𝐱) > 𝑃(𝐶 = 𝑐|𝐗 = 𝐱) 𝑐 ≠ 𝑐∗
, 𝑐 = 𝑐1,⋅⋅⋅, 𝑐𝐿
𝑃(𝐶|𝐗) =
𝑃(𝐗|𝐶)𝑃(𝐶)
𝑃(𝐗)
∝ 𝑃(𝐗|𝐶)𝑃(𝐶)
2/3/2024
Naïve Bayes
• Naïve Bayes Algorithm (for discrete input attributes)
– Learning Phase: Given a training set S,
• Output: conditional probability tables; for elements
– Test Phase: Given an unknown instance ,
• Look up tables to assign the label c* to X’ if
•
For each target value of 𝑐𝑖 (𝑐𝑖 = 𝑐1,⋅⋅⋅, 𝑐𝐿)
𝑃(𝐶 = 𝑐𝑖) ← estimate 𝑃(𝐶 = 𝑐𝑖) with examples in 𝐒;
For every attribute value 𝑎𝑗𝑘 of each attribute 𝑥𝑗 (𝑗 = 1,⋅⋅⋅, 𝑛; 𝑘 = 1,⋅⋅⋅, 𝑁𝑗)
𝑃(𝑋𝑗 = 𝑎𝑗𝑘|𝐶 = 𝑐𝑖) ← estimate 𝑃(𝑋𝑗 = 𝑎𝑗𝑘|𝐶 = 𝑐𝑖) with examples in 𝐒;
𝑥𝑗, 𝑁𝑗 × 𝐿
𝐗′
= (𝑎1
′
,⋅⋅⋅, 𝑎𝑛
′
)
[𝑃(𝑎1
′
|𝑐∗
) ⋅⋅⋅ 𝑃(𝑎𝑛
′
|𝑐∗
)]𝑃(𝑐∗
) > [𝑃(𝑎1
′
|𝑐) ⋅⋅⋅ 𝑃(𝑎𝑛
′
|𝑐)]𝑃(𝑐), 𝑐 ≠ 𝑐∗
, 𝑐 = 𝑐1,⋅⋅⋅, 𝑐𝐿
2/3/2024
Example
2/3/2024
Example: Learning phase
Outlook Play=Yes Play=No
Sunny 2/9 3/5
Overcast 4/9 0/5
Rain 3/9 2/5
Temperature Play=Yes Play=No
Hot 2/9 2/5
Mild 4/9 2/5
Cool 3/9 1/5
Humidity Play=Yes Play=No
High 3/9 4/5
Normal 6/9 1/5
Wind Play=Yes Play=No
Strong 3/9 3/5
Weak 6/9 2/5
P(Play=Yes) = 9/14 P(Play=No) = 5/14
2/3/2024
Example: test phase
–Given a new instance,
• x’=(Outlook=Sunny, Temperature=Cool, Humidity=High,
Wind=Strong)
–Look up tables
–MAP rule
P(Outlook=Sunny|Play=Yes) = 2/9
P(Temperature=Cool|Play=Yes) = 3/9
P(Huminity=High|Play=Yes) = 3/9
P(Wind=Strong|Play=Yes) = 3/9
P(Play=Yes) = 9/14
P(Outlook=Sunny|Play=No) = 3/5
P(Temperature=Cool|Play==No) = 1/5
P(Huminity=High|Play=No) = 4/5
P(Wind=Strong|Play=No) = 3/5
P(Play=No) = 5/14
P(Yes|x’): [P(Sunny|Yes)P(Cool|Yes)P(High|Yes)P(Strong|Yes)]P(Play=Yes) = 0.0053
P(No|x’): [P(Sunny|No) P(Cool|No)P(High|No)P(Strong|No)]P(Play=No) = 0.0206
Given the fact P(Yes|x’) < P(No|x’), we label x’ to be “No”.
2/3/2024
Relevant Issues
• Violation of Independence Assumption
– For many real world tasks,
– Nevertheless, naïve Bayes works surprisingly well anyway!
• Zero conditional probability Problem
– If no example contains the attribute value
– In this circumstance, during test
– For a remedy, conditional probabilities estimated with
𝑃(𝑋1,⋅⋅⋅, 𝑋𝑛|𝐶) ≠ 𝑃(𝑋1|𝐶) ⋅⋅⋅ 𝑃(𝑋𝑛|𝐶)
𝑋𝑗 = 𝑎𝑗𝑘, 𝑃(𝑋𝑗 = 𝑎𝑗𝑘|𝐶 = 𝑐𝑖) = 0
𝑃(𝑥1|𝑐𝑖) ⋅⋅⋅ 𝑃(𝑎𝑗𝑘|𝑐𝑖) ⋅⋅⋅ 𝑃(𝑥𝑛|𝑐𝑖) = 0
𝑃(𝑋𝑗 = 𝑎𝑗𝑘|𝐶 = 𝑐𝑖) =
𝑛𝑐 + 𝑚𝑝
𝑛 + 𝑚
𝑛𝑐: number of training examples for which 𝑋𝑗 = 𝑎𝑗𝑘 and C = 𝑐𝑖
𝑛: number of training examples for which 𝐶 = 𝑐𝑖
𝑝: prior estimate (usually, 𝑝 = 1/𝑡 for 𝑡 possible values of 𝑋𝑗)
𝑚: weight to prior (number of "virtual" examples, 𝑚 ≥ 1)
2/3/2024
Gaussian Naive Bayes classifier
• In Gaussian Naive Bayes, continuous values associated with each
feature are assumed to be distributed according to a Gaussian
distribution.
• A Gaussian distribution is also called Normal distribution.
• When plotted, it gives a bell shaped curve which is symmetric
about the mean of the feature values as shown below:
2/3/2024
Gaussian Naive Bayes classifier
• Updated table of prior probabilities for outlook feature is as
following:
• The likelihood of the features is assumed to be Gaussian, hence,
conditional probability is given by:
2/3/2024
Summary
• Naïve Bayes based on the independence assumption
• Training is very easy and fast; just requiring considering each attribute in each
class separately
• Test is straightforward; just looking up tables or calculating conditional
probabilities with normal distributions
• A popular generative model
• Performance competitive to most of state-of-the-art classifiers even in presence of
violating independence assumption
• Many successful applications, e.g., spam mail filtering
• Apart from classification, naïve Bayes can do more…
2/3/2024

More Related Content

Similar to baysian in machine learning in Supervised Learning .pptx

Data classification sammer
Data classification sammer Data classification sammer
Data classification sammer Sammer Qader
 
Distributional RL via Moment Matching
Distributional RL via Moment MatchingDistributional RL via Moment Matching
Distributional RL via Moment Matchingtaeseon ryu
 
Kernel Bayes Rule
Kernel Bayes RuleKernel Bayes Rule
Kernel Bayes RuleYan Xu
 
Gaussian Process Regression
Gaussian Process Regression  Gaussian Process Regression
Gaussian Process Regression SEMINARGROOT
 
Confirmatory Bayesian Online Change Point Detection in the Covariance Structu...
Confirmatory Bayesian Online Change Point Detection in the Covariance Structu...Confirmatory Bayesian Online Change Point Detection in the Covariance Structu...
Confirmatory Bayesian Online Change Point Detection in the Covariance Structu...JeeyeonHan
 
Gram-Schmidt process linear algbera.pptx
Gram-Schmidt process linear algbera.pptxGram-Schmidt process linear algbera.pptx
Gram-Schmidt process linear algbera.pptxMd. Al-Amin
 
tut07.pptx
tut07.pptxtut07.pptx
tut07.pptxEricWyld
 
Neo_Phase_1_Vectors_HN_S10_PPT.pptx
Neo_Phase_1_Vectors_HN_S10_PPT.pptxNeo_Phase_1_Vectors_HN_S10_PPT.pptx
Neo_Phase_1_Vectors_HN_S10_PPT.pptxYashrai65
 
Learning a nonlinear embedding by preserving class neibourhood structure 최종
Learning a nonlinear embedding by preserving class neibourhood structure   최종Learning a nonlinear embedding by preserving class neibourhood structure   최종
Learning a nonlinear embedding by preserving class neibourhood structure 최종WooSung Choi
 
Solution of equations and eigenvalue problems
Solution of equations and eigenvalue problemsSolution of equations and eigenvalue problems
Solution of equations and eigenvalue problemsSanthanam Krishnan
 
Optimum Engineering Design - Day 2b. Classical Optimization methods
Optimum Engineering Design - Day 2b. Classical Optimization methodsOptimum Engineering Design - Day 2b. Classical Optimization methods
Optimum Engineering Design - Day 2b. Classical Optimization methodsSantiagoGarridoBulln
 
Pattern recognition binoy 05-naive bayes classifier
Pattern recognition binoy 05-naive bayes classifierPattern recognition binoy 05-naive bayes classifier
Pattern recognition binoy 05-naive bayes classifier108kaushik
 
lecture 5 about lecture 5 about lecture lecture
lecture 5 about lecture 5 about lecture lecturelecture 5 about lecture 5 about lecture lecture
lecture 5 about lecture 5 about lecture lectureanxiousanoja
 
Probability and Statistics
Probability and StatisticsProbability and Statistics
Probability and StatisticsRoozbeh Sanaei
 

Similar to baysian in machine learning in Supervised Learning .pptx (20)

Data classification sammer
Data classification sammer Data classification sammer
Data classification sammer
 
Naive Bayes Presentation
Naive Bayes PresentationNaive Bayes Presentation
Naive Bayes Presentation
 
Distributional RL via Moment Matching
Distributional RL via Moment MatchingDistributional RL via Moment Matching
Distributional RL via Moment Matching
 
Kernel Bayes Rule
Kernel Bayes RuleKernel Bayes Rule
Kernel Bayes Rule
 
ML.pptx
ML.pptxML.pptx
ML.pptx
 
Gaussian Process Regression
Gaussian Process Regression  Gaussian Process Regression
Gaussian Process Regression
 
Confirmatory Bayesian Online Change Point Detection in the Covariance Structu...
Confirmatory Bayesian Online Change Point Detection in the Covariance Structu...Confirmatory Bayesian Online Change Point Detection in the Covariance Structu...
Confirmatory Bayesian Online Change Point Detection in the Covariance Structu...
 
Gram-Schmidt process linear algbera.pptx
Gram-Schmidt process linear algbera.pptxGram-Schmidt process linear algbera.pptx
Gram-Schmidt process linear algbera.pptx
 
Curve fitting
Curve fittingCurve fitting
Curve fitting
 
Curve fitting
Curve fittingCurve fitting
Curve fitting
 
tut07.pptx
tut07.pptxtut07.pptx
tut07.pptx
 
Neo_Phase_1_Vectors_HN_S10_PPT.pptx
Neo_Phase_1_Vectors_HN_S10_PPT.pptxNeo_Phase_1_Vectors_HN_S10_PPT.pptx
Neo_Phase_1_Vectors_HN_S10_PPT.pptx
 
Learning a nonlinear embedding by preserving class neibourhood structure 최종
Learning a nonlinear embedding by preserving class neibourhood structure   최종Learning a nonlinear embedding by preserving class neibourhood structure   최종
Learning a nonlinear embedding by preserving class neibourhood structure 최종
 
Covariance.pdf
Covariance.pdfCovariance.pdf
Covariance.pdf
 
Solution of equations and eigenvalue problems
Solution of equations and eigenvalue problemsSolution of equations and eigenvalue problems
Solution of equations and eigenvalue problems
 
Optimum Engineering Design - Day 2b. Classical Optimization methods
Optimum Engineering Design - Day 2b. Classical Optimization methodsOptimum Engineering Design - Day 2b. Classical Optimization methods
Optimum Engineering Design - Day 2b. Classical Optimization methods
 
ABC workshop: 17w5025
ABC workshop: 17w5025ABC workshop: 17w5025
ABC workshop: 17w5025
 
Pattern recognition binoy 05-naive bayes classifier
Pattern recognition binoy 05-naive bayes classifierPattern recognition binoy 05-naive bayes classifier
Pattern recognition binoy 05-naive bayes classifier
 
lecture 5 about lecture 5 about lecture lecture
lecture 5 about lecture 5 about lecture lecturelecture 5 about lecture 5 about lecture lecture
lecture 5 about lecture 5 about lecture lecture
 
Probability and Statistics
Probability and StatisticsProbability and Statistics
Probability and Statistics
 

Recently uploaded

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 

Recently uploaded (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 

baysian in machine learning in Supervised Learning .pptx

  • 2. Outline • Background • Probability Basics • Probabilistic Classification • Naïve Bayes • Example: Play Tennis • Relevant Issues • Conclusions 2/3/2024
  • 3. A Naive Bayes classifier • is a probabilistic machine learning model that’s used for classification task. • The crux of the classifier is based on the Bayes theorem. • Using Bayes theorem, we can find the probability of A happening, given that B has occurred. • Here, B is the evidence and A is the hypothesis. • The assumption made here is that the predictors/features are independent. 2/3/2024
  • 4. Probability Basics • Prior, conditional and joint probability – Prior probability: – Conditional probability: – Joint probability: – Relationship: – Independence: • Bayesian Rule 𝑃(𝑋) 𝑃(𝑋1|𝑋2), 𝑃(𝑋2|𝑋1) 𝐗 = 𝑋1, 𝑋2 ⇒ 𝑃(𝐗) = 𝑃(𝑋1 , 𝑋2) 𝑃(𝑋1 , 𝑋2) = 𝑃(𝑋2|𝑋1)𝑃(𝑋1) = 𝑃(𝑋1|𝑋2)𝑃(𝑋2) 𝑃 𝑋2 𝑋1 = 𝑃 𝑋2 , 𝑃 𝑋1 𝑋2 = 𝑃 𝑋1 , => 𝑃(𝑋1 , 𝑋2) = 𝑃(𝑋1)𝑃(𝑋2) 𝑃(𝐶|𝐗) = 𝑃(𝐗|𝐶)𝑃(𝐶) 𝑃(𝐗) 𝑃𝑜𝑠𝑡𝑒𝑟𝑖𝑜𝑟 = 𝐿𝑖𝑘𝑒𝑙𝑖ℎ𝑜𝑜𝑑 × 𝑃𝑟𝑖𝑜𝑟 𝐸𝑣𝑖𝑑𝑒𝑛𝑐𝑒 2/3/2024
  • 5. Example by Dieter Fox taken 2/3/2024
  • 8. Probabilistic Classification • Establishing a probabilistic model for classification – Discriminative model: – Generative model: • MAP classification rule – MAP: Maximum A Posterior – Assign x to c* if • Generative classification with the MAP rule – Apply Bayesian rule to convert: 𝑃(𝐶|𝐗) 𝐶 = 𝑐1,⋅⋅⋅, 𝑐𝐿, 𝐗 = (𝑋1,⋅⋅⋅, 𝑋𝑛) 𝑃(𝐗|𝐶) 𝐶 = 𝑐1,⋅⋅⋅, 𝑐𝐿, 𝐗 = (𝑋1,⋅⋅⋅, 𝑋𝑛) 𝑃(𝐶 = 𝑐∗ |𝐗 = 𝐱) > 𝑃(𝐶 = 𝑐|𝐗 = 𝐱) 𝑐 ≠ 𝑐∗ , 𝑐 = 𝑐1,⋅⋅⋅, 𝑐𝐿 𝑃(𝐶|𝐗) = 𝑃(𝐗|𝐶)𝑃(𝐶) 𝑃(𝐗) ∝ 𝑃(𝐗|𝐶)𝑃(𝐶) 2/3/2024
  • 9. Naïve Bayes • Naïve Bayes Algorithm (for discrete input attributes) – Learning Phase: Given a training set S, • Output: conditional probability tables; for elements – Test Phase: Given an unknown instance , • Look up tables to assign the label c* to X’ if • For each target value of 𝑐𝑖 (𝑐𝑖 = 𝑐1,⋅⋅⋅, 𝑐𝐿) 𝑃(𝐶 = 𝑐𝑖) ← estimate 𝑃(𝐶 = 𝑐𝑖) with examples in 𝐒; For every attribute value 𝑎𝑗𝑘 of each attribute 𝑥𝑗 (𝑗 = 1,⋅⋅⋅, 𝑛; 𝑘 = 1,⋅⋅⋅, 𝑁𝑗) 𝑃(𝑋𝑗 = 𝑎𝑗𝑘|𝐶 = 𝑐𝑖) ← estimate 𝑃(𝑋𝑗 = 𝑎𝑗𝑘|𝐶 = 𝑐𝑖) with examples in 𝐒; 𝑥𝑗, 𝑁𝑗 × 𝐿 𝐗′ = (𝑎1 ′ ,⋅⋅⋅, 𝑎𝑛 ′ ) [𝑃(𝑎1 ′ |𝑐∗ ) ⋅⋅⋅ 𝑃(𝑎𝑛 ′ |𝑐∗ )]𝑃(𝑐∗ ) > [𝑃(𝑎1 ′ |𝑐) ⋅⋅⋅ 𝑃(𝑎𝑛 ′ |𝑐)]𝑃(𝑐), 𝑐 ≠ 𝑐∗ , 𝑐 = 𝑐1,⋅⋅⋅, 𝑐𝐿 2/3/2024
  • 11. Example: Learning phase Outlook Play=Yes Play=No Sunny 2/9 3/5 Overcast 4/9 0/5 Rain 3/9 2/5 Temperature Play=Yes Play=No Hot 2/9 2/5 Mild 4/9 2/5 Cool 3/9 1/5 Humidity Play=Yes Play=No High 3/9 4/5 Normal 6/9 1/5 Wind Play=Yes Play=No Strong 3/9 3/5 Weak 6/9 2/5 P(Play=Yes) = 9/14 P(Play=No) = 5/14 2/3/2024
  • 12. Example: test phase –Given a new instance, • x’=(Outlook=Sunny, Temperature=Cool, Humidity=High, Wind=Strong) –Look up tables –MAP rule P(Outlook=Sunny|Play=Yes) = 2/9 P(Temperature=Cool|Play=Yes) = 3/9 P(Huminity=High|Play=Yes) = 3/9 P(Wind=Strong|Play=Yes) = 3/9 P(Play=Yes) = 9/14 P(Outlook=Sunny|Play=No) = 3/5 P(Temperature=Cool|Play==No) = 1/5 P(Huminity=High|Play=No) = 4/5 P(Wind=Strong|Play=No) = 3/5 P(Play=No) = 5/14 P(Yes|x’): [P(Sunny|Yes)P(Cool|Yes)P(High|Yes)P(Strong|Yes)]P(Play=Yes) = 0.0053 P(No|x’): [P(Sunny|No) P(Cool|No)P(High|No)P(Strong|No)]P(Play=No) = 0.0206 Given the fact P(Yes|x’) < P(No|x’), we label x’ to be “No”. 2/3/2024
  • 13. Relevant Issues • Violation of Independence Assumption – For many real world tasks, – Nevertheless, naïve Bayes works surprisingly well anyway! • Zero conditional probability Problem – If no example contains the attribute value – In this circumstance, during test – For a remedy, conditional probabilities estimated with 𝑃(𝑋1,⋅⋅⋅, 𝑋𝑛|𝐶) ≠ 𝑃(𝑋1|𝐶) ⋅⋅⋅ 𝑃(𝑋𝑛|𝐶) 𝑋𝑗 = 𝑎𝑗𝑘, 𝑃(𝑋𝑗 = 𝑎𝑗𝑘|𝐶 = 𝑐𝑖) = 0 𝑃(𝑥1|𝑐𝑖) ⋅⋅⋅ 𝑃(𝑎𝑗𝑘|𝑐𝑖) ⋅⋅⋅ 𝑃(𝑥𝑛|𝑐𝑖) = 0 𝑃(𝑋𝑗 = 𝑎𝑗𝑘|𝐶 = 𝑐𝑖) = 𝑛𝑐 + 𝑚𝑝 𝑛 + 𝑚 𝑛𝑐: number of training examples for which 𝑋𝑗 = 𝑎𝑗𝑘 and C = 𝑐𝑖 𝑛: number of training examples for which 𝐶 = 𝑐𝑖 𝑝: prior estimate (usually, 𝑝 = 1/𝑡 for 𝑡 possible values of 𝑋𝑗) 𝑚: weight to prior (number of "virtual" examples, 𝑚 ≥ 1) 2/3/2024
  • 14. Gaussian Naive Bayes classifier • In Gaussian Naive Bayes, continuous values associated with each feature are assumed to be distributed according to a Gaussian distribution. • A Gaussian distribution is also called Normal distribution. • When plotted, it gives a bell shaped curve which is symmetric about the mean of the feature values as shown below: 2/3/2024
  • 15. Gaussian Naive Bayes classifier • Updated table of prior probabilities for outlook feature is as following: • The likelihood of the features is assumed to be Gaussian, hence, conditional probability is given by: 2/3/2024
  • 16. Summary • Naïve Bayes based on the independence assumption • Training is very easy and fast; just requiring considering each attribute in each class separately • Test is straightforward; just looking up tables or calculating conditional probabilities with normal distributions • A popular generative model • Performance competitive to most of state-of-the-art classifiers even in presence of violating independence assumption • Many successful applications, e.g., spam mail filtering • Apart from classification, naïve Bayes can do more… 2/3/2024

Editor's Notes

  1. That is presence of one particular feature does not affect the other. Hence it is called naïve.
  2. Bayes’ Theorem finds the probability of an event occurring given the probability of another event that has already occurred. Bayes’ theorem is stated mathematically as the following equation: where X and C are events and P(X) ≠ 0. Basically, we are trying to find probability of event C, given the event X is true. Event X is also termed as evidence. P(C) is the priori of A (the prior probability, i.e. Probability of event before evidence is seen). The evidence is an attribute value of an unknown instance(here, it is event X). P(C|X) is a posteriori probability of B, i.e. probability of event after evidence is seen.
  3. 2/3/2024
  4. 2/3/2024
  5. 2/3/2024