SlideShare a Scribd company logo
2
Most read
13
Most read
18
Most read
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
Naïve Bayes Classifier
structure and functionalities
PGDM Business Analytics : Data Mining - I
Arunabha Saha1,2
1
Department of Computer Science & IT, Ananda Mohan College
2
Department of Computer Science, Vidyasagar College
July 29, 2019
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 1 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
what is classifier
classification is a supervised learning mechanism in which
the computer program learns from the given input dataset
and then use this experience to classify new observation.
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 2 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
what is classifier
classification is a supervised learning mechanism in which
the computer program learns from the given input dataset
and then use this experience to classify new observation.
it could be binary or multiclass classification
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 2 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
what is classifier
classification is a supervised learning mechanism in which
the computer program learns from the given input dataset
and then use this experience to classify new observation.
it could be binary or multiclass classification
several types of classifiers :
– linear classifier: logistic regression, naïve bayes
classifer
– nearest neighbour
– support vector machine
– decision tree
– random forest
– neural networks
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 2 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
background
Naïve Bayes Classifiers(NBC) are a family of probabilistic
classification algorithms based upon Bayes’ theorem with an
assumption of strong(naive) independence between the
features i.e. features are mutually exclusive or independent of
each other.
Bayes’ Theorem
Let A1, A2, ...., An are mutually exclusive events forming a
sample space S. Let B be any event from the same sample
space, such that P(B) > 0 then,
P(Ai |B) =
P(B|Ai )P(Ai )
n
j=1
P(B|Aj )P(Aj )
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 3 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
Bayes’ Theorem
Simple form:
P(A|B) = P(B|A)P(A)
P(B)
where A and B are events and P(B) = 0
•P(A|B) is conditional probability; likelihood of event A
occurring given that B is true
•P(B|A) is conditional probability; likelihood of event B
occurring given that A is true
•P(A) and P(B) is the probability of event A and B;
independent of each other
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 4 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
Bayes’ Theorem: Interpretation
Bayes’ theorem allows to update predicted probabilities of
an event by incorporating new information.1
Bayes’ theorem incorporates prior probability distributions
in order to generate posterior probabilities.
P(A) is the prior probability of event A, before new data is
collected.
P(A|B) is the posterior probability of event A occurring
given that event B has occurred.
1http://yudkowsky.net/rational/bayes
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 5 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
Bayes’ Theorem: Example
An aircraft emergency locator transmitter (ELT) is a device
designed to transmit a signal in the case of a crash. The Altigauge
Manufacturing Co. makes 80% of the ELTs, the Bryant Co. makes
15% of them, and the Chartair Co. makes the other 5%. The ELTs
made by Altigauge have a 4% rate of defects, the Bryant ELTs have
a 6% rate of defects, and the Chartair ELTs have a 9% rate of
defects.
a. If an ELT is randomly selected from the general population of
all ELTs, find the probability that it was made by the Altigauge
Manufacturing Co.
b. If a randomly selected ELT is then tested and is found to be
defective, find the probability that it was made by the
Altigauge Manufacturing Co.
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 6 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
Solution: Bayes’ Rule
A = ELT manufactured by Altigauge
B = ELT manufactured by Bryant
C = ELT manufactured by Chartair
D = defected ELT
D = not defected ELT
a. ELT randomly selected, probability its from Altigauge P(A) = 0.8
b. ELT found defective, probability it is from Altigauge P(A|D);
prob. will be revised
P(A) = 0.80, P(B) = 0.15, P(C) = 0.05
P(D|A) = 0.04, P(D|B) = 0.06, P(D|C) = 0.09
P(A|D) = P(D|A)∗P(A)
[P(D|A)∗P(A)+P(D|B)∗P(B)+P(D|C)∗P(C)]
0.703
hence we have solved it using the Bayes’ rule directly.
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 7 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
Solution: Table method
Now we will solve it with explicit value.
Let total number if ELT manufactured is N = 10,000.
D D Total
A(Altigauge) 320 7680 8000
B(Bryant) 90 1410 1500
C(Chartair) 45 455 500
Total 455 9545 10,000
Now a ELT is found defective during the test and the probability of
it being from Altigauge is 320/455 0.703
hence the result in order with the result from the previous method.
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 8 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
Naïve Bayes Classifier: Model
It is a conditional probability model. A problem instance to be
classified, n independent features (variables) represented by a vector
x = (x1, . . . , xn), it assigns to this instance probabilities,
P(Ck |x1, . . . , xn) for each of K possible outcomes.
Using Bayes’s theorem, the conditional probability can be expressed
as,
P(Ck |x) = P(Ck )P(x|Ck )
P(x)
it describes, posterior = (prior x likelihood)/evidence
The numerator is eqv. to joint probability P(Ck , x1, . . . , xn). Using
chain rule,
P(Ck , x1, . . . , xn) =
P(x1|x2, . . . , xn, Ck )P(x2|x3, . . . , xn, Ck ) . . . P(xn−1|xn, Ck )P(xn|Ck )P(Ck )
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 9 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
Naïve Bayes Classifier: Model
naive assumption: are features in x are mutually independent
P(xi |xi+1, . . . , xn, Ck ) = P(xi |Ck ). So it expressed as,
P(Ck |x1, . . . , xn) ∝ P(Ck , x1, . . . , xn)
= P(Ck )
n
i=1
P(xi |Ck )
the conditional distribution over class variable C is,
P(Ck |x1, . . . , xn) = 1
Z
P(Ck )
n
i=1
P(xi |Ck )
where the evidence Z = P(x) =
k
P(Ck )P(x|Ck ) is constant if the
feature vector x is known.
constructing a classifier:
Hence the case is binary, but in case of multivariate classification we
need to find a class with maximum probability; it is known as
maximum a posteriori rule. Say assign a class label ˆy = Ck for
some k,
ˆy = argmax
k∈1,...,K
P(Ck )
n
i=1
P(xi |Ck )
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 10 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
NBC: Algorithm
Classification Steps:
1 Read the dataset. It consists of two parts, feature matrix
and response vector.
2 Prepare the frequency table for each feature.
3 Prepare the likelihood table for each feature.
4 Apply Bayes’s rule to classify the response depending
upon the observation.
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 11 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
NBC:Example
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 12 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
NBC:Example
now what is the probability of playing if
outcast = sunny
temp = hot
humidity = normal
wind = false
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 13 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
NBC:Example
now what is the probability of playing if
outcast = sunny
temp = hot
humidity = normal
wind = false
Limitations of NBC
incomplete training data : if any instance is 0 entire
conditional probability will collapse;
Laplace correction: asssign low probabilities so that prob.
computation doesn’t become 0
continuous variable: need to compute probability densities
non-independence of features: most important weakness
ignore correlated attributes; if its unknown which are
correlated then need to run correlation tests.
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 13 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
NBC: Application
Few applications are:
credit/loan approval analysis
medical diagnosis
weather forcasting
fraud analysis
spam filtering
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 14 / 15
Naïve Bayes Classifier
Arunabha Saha
Introduction
Classifier Overview
Background
Bayes’ Theorem
Interpretation
Example
Solution 1
Solution 2
Naive Bayes Classifier
NBC Model
NBC Algorithm
NBC example
NBC Appplication
End
Thank You
Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 15 / 15

More Related Content

PDF
Naive Bayes Classifier Tutorial | Naive Bayes Classifier Example | Naive Baye...
PDF
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
PPTX
Decision Tree Classification Algorithm.pptx
PPT
Decision Tree, Naive Bayes, Association Rule Mining, Support Vector Machine, ...
PPTX
Naive Bayes Presentation
PPTX
Feature Selection in Machine Learning
PDF
Unsupervised Learning in Machine Learning
PDF
L2. Evaluating Machine Learning Algorithms I
Naive Bayes Classifier Tutorial | Naive Bayes Classifier Example | Naive Baye...
An Introduction to Supervised Machine Learning and Pattern Classification: Th...
Decision Tree Classification Algorithm.pptx
Decision Tree, Naive Bayes, Association Rule Mining, Support Vector Machine, ...
Naive Bayes Presentation
Feature Selection in Machine Learning
Unsupervised Learning in Machine Learning
L2. Evaluating Machine Learning Algorithms I

What's hot (20)

PDF
Naive Bayes
PPT
Naive bayes
PPTX
Naive bayes
ODP
NAIVE BAYES CLASSIFIER
PDF
Bayes Belief Networks
PDF
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
PDF
Classification Based Machine Learning Algorithms
PDF
1. Linear Algebra for Machine Learning: Linear Systems
PDF
Introduction to Machine Learning Classifiers
PDF
Naive Bayes Classifier
PPTX
Random forest
PDF
Understanding Bagging and Boosting
PDF
Bias and variance trade off
PPTX
Support vector machines (svm)
PPTX
Random forest
PDF
Logistic regression in Machine Learning
PDF
Bayesian networks
PDF
03 Machine Learning Linear Algebra
PPTX
Machine Learning lecture6(regularization)
PPTX
Random forest algorithm
Naive Bayes
Naive bayes
Naive bayes
NAIVE BAYES CLASSIFIER
Bayes Belief Networks
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Classification Based Machine Learning Algorithms
1. Linear Algebra for Machine Learning: Linear Systems
Introduction to Machine Learning Classifiers
Naive Bayes Classifier
Random forest
Understanding Bagging and Boosting
Bias and variance trade off
Support vector machines (svm)
Random forest
Logistic regression in Machine Learning
Bayesian networks
03 Machine Learning Linear Algebra
Machine Learning lecture6(regularization)
Random forest algorithm
Ad

Similar to Naive Bayes Classifier (20)

PDF
Bayesianclassifiers
PPTX
Navies bayes
PPTX
Naive Bayesian classifier Naive Bayesian classifier Naive Bayesian classifier
PDF
19BayesTheoremClassification19BayesTheoremClassification.ppt
PPTX
Naïve Bayes Classifier Algorithm.pptx
PPTX
Naïve Bayes Classifier Algorithm.pptx
PDF
Bayes 6
PPTX
Naive Bayes Classifier using R.
DOCX
You need to have JavaScript enabled in order to access this site..docx
DOCX
Copyright © 2014 EMC Corporation. All rights reserved.Copy
PPT
Machine learning by Dr. Vivek Vijay and Dr. Sandeep Yadav
PPTX
Naive Bayes classifier ( Ai Ml 182118).pptx
DOCX
Copyright © 2014 EMC Corporation. All rights reserved.Copy.docx
PPT
Unit-2.ppt
PPTX
"Naive Bayes Classifier" @ Papers We Love Bucharest
PDF
Bayesian classification
PPTX
Pattern recognition binoy 05-naive bayes classifier
PPT
BAYESIAN theorem and implementation of i
PDF
NAIVE BAYES ALGORITHM
PPTX
Bayer's Theorem Naive Bayer's classifier
Bayesianclassifiers
Navies bayes
Naive Bayesian classifier Naive Bayesian classifier Naive Bayesian classifier
19BayesTheoremClassification19BayesTheoremClassification.ppt
Naïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptx
Bayes 6
Naive Bayes Classifier using R.
You need to have JavaScript enabled in order to access this site..docx
Copyright © 2014 EMC Corporation. All rights reserved.Copy
Machine learning by Dr. Vivek Vijay and Dr. Sandeep Yadav
Naive Bayes classifier ( Ai Ml 182118).pptx
Copyright © 2014 EMC Corporation. All rights reserved.Copy.docx
Unit-2.ppt
"Naive Bayes Classifier" @ Papers We Love Bucharest
Bayesian classification
Pattern recognition binoy 05-naive bayes classifier
BAYESIAN theorem and implementation of i
NAIVE BAYES ALGORITHM
Bayer's Theorem Naive Bayer's classifier
Ad

More from Arunabha Saha (12)

PDF
Manchester & Differential Manchester encoding scheme
PDF
Polar-NRZ & Polar-RZ encoding schemes
PDF
Baseline Wandering
PDF
Unipolar Encoding Techniques: NRZ & RZ
PDF
Introduction to Line Coding Schemes
PDF
Introduction to Channel Capacity | DCNIT-LDTalks-1
PDF
Data Communication, Networking & Internet Technology Lecture Series(DCNIT-LDT...
PDF
Introduction to Quantum Secret Sharing
PDF
Introduction to Quantum Teleportation & BBCJPW Protocol
PDF
Introduction to Quantum Computation. Part - 1
PDF
Introduction to Quantum Computation. Part - 2
PDF
Brief Introduction to Boltzmann Machine
Manchester & Differential Manchester encoding scheme
Polar-NRZ & Polar-RZ encoding schemes
Baseline Wandering
Unipolar Encoding Techniques: NRZ & RZ
Introduction to Line Coding Schemes
Introduction to Channel Capacity | DCNIT-LDTalks-1
Data Communication, Networking & Internet Technology Lecture Series(DCNIT-LDT...
Introduction to Quantum Secret Sharing
Introduction to Quantum Teleportation & BBCJPW Protocol
Introduction to Quantum Computation. Part - 1
Introduction to Quantum Computation. Part - 2
Brief Introduction to Boltzmann Machine

Recently uploaded (20)

PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PPTX
Computer network topology notes for revision
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PPT
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PDF
Mega Projects Data Mega Projects Data
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPTX
IB Computer Science - Internal Assessment.pptx
PDF
Introduction to Business Data Analytics.
PPTX
Major-Components-ofNKJNNKNKNKNKronment.pptx
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PDF
Lecture1 pattern recognition............
PPTX
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
Computer network topology notes for revision
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
Miokarditis (Inflamasi pada Otot Jantung)
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
STUDY DESIGN details- Lt Col Maksud (21).pptx
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
Mega Projects Data Mega Projects Data
Business Ppt On Nestle.pptx huunnnhhgfvu
IB Computer Science - Internal Assessment.pptx
Introduction to Business Data Analytics.
Major-Components-ofNKJNNKNKNKNKronment.pptx
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
Lecture1 pattern recognition............
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
Data_Analytics_and_PowerBI_Presentation.pptx

Naive Bayes Classifier

  • 1. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End Naïve Bayes Classifier structure and functionalities PGDM Business Analytics : Data Mining - I Arunabha Saha1,2 1 Department of Computer Science & IT, Ananda Mohan College 2 Department of Computer Science, Vidyasagar College July 29, 2019 Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 1 / 15
  • 2. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End what is classifier classification is a supervised learning mechanism in which the computer program learns from the given input dataset and then use this experience to classify new observation. Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 2 / 15
  • 3. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End what is classifier classification is a supervised learning mechanism in which the computer program learns from the given input dataset and then use this experience to classify new observation. it could be binary or multiclass classification Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 2 / 15
  • 4. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End what is classifier classification is a supervised learning mechanism in which the computer program learns from the given input dataset and then use this experience to classify new observation. it could be binary or multiclass classification several types of classifiers : – linear classifier: logistic regression, naïve bayes classifer – nearest neighbour – support vector machine – decision tree – random forest – neural networks Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 2 / 15
  • 5. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End background Naïve Bayes Classifiers(NBC) are a family of probabilistic classification algorithms based upon Bayes’ theorem with an assumption of strong(naive) independence between the features i.e. features are mutually exclusive or independent of each other. Bayes’ Theorem Let A1, A2, ...., An are mutually exclusive events forming a sample space S. Let B be any event from the same sample space, such that P(B) > 0 then, P(Ai |B) = P(B|Ai )P(Ai ) n j=1 P(B|Aj )P(Aj ) Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 3 / 15
  • 6. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End Bayes’ Theorem Simple form: P(A|B) = P(B|A)P(A) P(B) where A and B are events and P(B) = 0 •P(A|B) is conditional probability; likelihood of event A occurring given that B is true •P(B|A) is conditional probability; likelihood of event B occurring given that A is true •P(A) and P(B) is the probability of event A and B; independent of each other Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 4 / 15
  • 7. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End Bayes’ Theorem: Interpretation Bayes’ theorem allows to update predicted probabilities of an event by incorporating new information.1 Bayes’ theorem incorporates prior probability distributions in order to generate posterior probabilities. P(A) is the prior probability of event A, before new data is collected. P(A|B) is the posterior probability of event A occurring given that event B has occurred. 1http://yudkowsky.net/rational/bayes Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 5 / 15
  • 8. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End Bayes’ Theorem: Example An aircraft emergency locator transmitter (ELT) is a device designed to transmit a signal in the case of a crash. The Altigauge Manufacturing Co. makes 80% of the ELTs, the Bryant Co. makes 15% of them, and the Chartair Co. makes the other 5%. The ELTs made by Altigauge have a 4% rate of defects, the Bryant ELTs have a 6% rate of defects, and the Chartair ELTs have a 9% rate of defects. a. If an ELT is randomly selected from the general population of all ELTs, find the probability that it was made by the Altigauge Manufacturing Co. b. If a randomly selected ELT is then tested and is found to be defective, find the probability that it was made by the Altigauge Manufacturing Co. Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 6 / 15
  • 9. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End Solution: Bayes’ Rule A = ELT manufactured by Altigauge B = ELT manufactured by Bryant C = ELT manufactured by Chartair D = defected ELT D = not defected ELT a. ELT randomly selected, probability its from Altigauge P(A) = 0.8 b. ELT found defective, probability it is from Altigauge P(A|D); prob. will be revised P(A) = 0.80, P(B) = 0.15, P(C) = 0.05 P(D|A) = 0.04, P(D|B) = 0.06, P(D|C) = 0.09 P(A|D) = P(D|A)∗P(A) [P(D|A)∗P(A)+P(D|B)∗P(B)+P(D|C)∗P(C)] 0.703 hence we have solved it using the Bayes’ rule directly. Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 7 / 15
  • 10. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End Solution: Table method Now we will solve it with explicit value. Let total number if ELT manufactured is N = 10,000. D D Total A(Altigauge) 320 7680 8000 B(Bryant) 90 1410 1500 C(Chartair) 45 455 500 Total 455 9545 10,000 Now a ELT is found defective during the test and the probability of it being from Altigauge is 320/455 0.703 hence the result in order with the result from the previous method. Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 8 / 15
  • 11. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End Naïve Bayes Classifier: Model It is a conditional probability model. A problem instance to be classified, n independent features (variables) represented by a vector x = (x1, . . . , xn), it assigns to this instance probabilities, P(Ck |x1, . . . , xn) for each of K possible outcomes. Using Bayes’s theorem, the conditional probability can be expressed as, P(Ck |x) = P(Ck )P(x|Ck ) P(x) it describes, posterior = (prior x likelihood)/evidence The numerator is eqv. to joint probability P(Ck , x1, . . . , xn). Using chain rule, P(Ck , x1, . . . , xn) = P(x1|x2, . . . , xn, Ck )P(x2|x3, . . . , xn, Ck ) . . . P(xn−1|xn, Ck )P(xn|Ck )P(Ck ) Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 9 / 15
  • 12. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End Naïve Bayes Classifier: Model naive assumption: are features in x are mutually independent P(xi |xi+1, . . . , xn, Ck ) = P(xi |Ck ). So it expressed as, P(Ck |x1, . . . , xn) ∝ P(Ck , x1, . . . , xn) = P(Ck ) n i=1 P(xi |Ck ) the conditional distribution over class variable C is, P(Ck |x1, . . . , xn) = 1 Z P(Ck ) n i=1 P(xi |Ck ) where the evidence Z = P(x) = k P(Ck )P(x|Ck ) is constant if the feature vector x is known. constructing a classifier: Hence the case is binary, but in case of multivariate classification we need to find a class with maximum probability; it is known as maximum a posteriori rule. Say assign a class label ˆy = Ck for some k, ˆy = argmax k∈1,...,K P(Ck ) n i=1 P(xi |Ck ) Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 10 / 15
  • 13. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End NBC: Algorithm Classification Steps: 1 Read the dataset. It consists of two parts, feature matrix and response vector. 2 Prepare the frequency table for each feature. 3 Prepare the likelihood table for each feature. 4 Apply Bayes’s rule to classify the response depending upon the observation. Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 11 / 15
  • 14. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End NBC:Example Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 12 / 15
  • 15. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End NBC:Example now what is the probability of playing if outcast = sunny temp = hot humidity = normal wind = false Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 13 / 15
  • 16. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End NBC:Example now what is the probability of playing if outcast = sunny temp = hot humidity = normal wind = false Limitations of NBC incomplete training data : if any instance is 0 entire conditional probability will collapse; Laplace correction: asssign low probabilities so that prob. computation doesn’t become 0 continuous variable: need to compute probability densities non-independence of features: most important weakness ignore correlated attributes; if its unknown which are correlated then need to run correlation tests. Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 13 / 15
  • 17. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End NBC: Application Few applications are: credit/loan approval analysis medical diagnosis weather forcasting fraud analysis spam filtering Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 14 / 15
  • 18. Naïve Bayes Classifier Arunabha Saha Introduction Classifier Overview Background Bayes’ Theorem Interpretation Example Solution 1 Solution 2 Naive Bayes Classifier NBC Model NBC Algorithm NBC example NBC Appplication End Thank You Arunabha Saha (AMC, VC) Naïve Bayes Classifier July 29, 2019 15 / 15