際際滷

際際滷Share a Scribd company logo
Bayes and Na誰ve Bayes
3/31/2020 Shivani Saluja 1
3/31/2020 Shivani Saluja 2
3/31/2020 Shivani Saluja 3
3/31/2020 Shivani Saluja 4
3/31/2020 Shivani Saluja 5
Types of Probability
 The representation for naive Bayes is probabilities.
 A list of probabilities are stored to file for a learned naive Bayes
model. This includes:
 Class Probabilities: The probabilities of each class in the training
dataset.
 Conditional Probabilities: The conditional probabilities of each input
value given each class value.
3/31/2020 Shivani Saluja 6
Na誰ve Bayes
 It is a classification technique based on Bayes Theorem with an assumption of
independence among predictors. In simple terms, a Naive Bayes classifier assumes that
the presence of a particular feature in a class is unrelated to the presence of any other
feature.
 For example, a fruit may be considered to be an apple if it is red, round, and about 3
inches in diameter. Even if these features depend on each other or upon the existence of
the other features, all of these properties independently contribute to the probability that
this fruit is an apple and that is why it is known as Naive.
 Naive Bayes model is easy to build and particularly useful for very large data sets
3/31/2020 Shivani Saluja 7
Na誰ve Bayes
 P(c|x) is the posterior probability of class (c, target)
given predictor (x, attributes).
 P(c) is the prior probability of class.
 P(x|c) is the likelihood which is the probability
of predictor given class.
 P(x) is the prior probability of predictor.

3/31/2020 Shivani Saluja 8
Calculating Class Probabilities
The class probabilities are simply the frequency of instances that
belong to each class divided by the total number of instances.
 For example in a binary classification the probability of an instance
belonging to class 1 would be calculated as:
 P(class=1) = count(class=1) / (count(class=0) + count(class=1))
 In the simplest case each class would have the probability of 0.5 or
50% for a binary classification problem with the same number of
instances in each class.
3/31/2020 Shivani Saluja 9
Conditional Probability
 The conditional probabilities are the frequency of each attribute value for a given
class value divided by the frequency of instances with that class value.
 For example, if a weather attribute had the values sunny and rainy and the
class attribute had the class values go-out and stay-home, then the
conditional probabilities of each weather value for each class value could be
calculated as:
 P(weather=sunny|class=go-out) = count(instances with weather=sunny and
class=go-out) / count(instances with class=go-out)
 P(weather=sunny|class=stay-home) = count(instances with weather=sunny and
class=stay-home) / count(instances with class=stay-home)
 P(weather=rainy|class=go-out) = count(instances with weather=rainy and
class=go-out) / count(instances with class=go-out)
 P(weather=rainy|class=stay-home) = count(instances with weather=rainy and
class=stay-home) / count(instances with class=stay-home)
3/31/2020 Shivani Saluja 10
Na誰ve Bayes
3/31/2020 Shivani Saluja 11
3/31/2020 Shivani Saluja 12

More Related Content

Bayes and naive bayes

  • 1. Bayes and Na誰ve Bayes 3/31/2020 Shivani Saluja 1
  • 6. Types of Probability The representation for naive Bayes is probabilities. A list of probabilities are stored to file for a learned naive Bayes model. This includes: Class Probabilities: The probabilities of each class in the training dataset. Conditional Probabilities: The conditional probabilities of each input value given each class value. 3/31/2020 Shivani Saluja 6
  • 7. Na誰ve Bayes It is a classification technique based on Bayes Theorem with an assumption of independence among predictors. In simple terms, a Naive Bayes classifier assumes that the presence of a particular feature in a class is unrelated to the presence of any other feature. For example, a fruit may be considered to be an apple if it is red, round, and about 3 inches in diameter. Even if these features depend on each other or upon the existence of the other features, all of these properties independently contribute to the probability that this fruit is an apple and that is why it is known as Naive. Naive Bayes model is easy to build and particularly useful for very large data sets 3/31/2020 Shivani Saluja 7
  • 8. Na誰ve Bayes P(c|x) is the posterior probability of class (c, target) given predictor (x, attributes). P(c) is the prior probability of class. P(x|c) is the likelihood which is the probability of predictor given class. P(x) is the prior probability of predictor. 3/31/2020 Shivani Saluja 8
  • 9. Calculating Class Probabilities The class probabilities are simply the frequency of instances that belong to each class divided by the total number of instances. For example in a binary classification the probability of an instance belonging to class 1 would be calculated as: P(class=1) = count(class=1) / (count(class=0) + count(class=1)) In the simplest case each class would have the probability of 0.5 or 50% for a binary classification problem with the same number of instances in each class. 3/31/2020 Shivani Saluja 9
  • 10. Conditional Probability The conditional probabilities are the frequency of each attribute value for a given class value divided by the frequency of instances with that class value. For example, if a weather attribute had the values sunny and rainy and the class attribute had the class values go-out and stay-home, then the conditional probabilities of each weather value for each class value could be calculated as: P(weather=sunny|class=go-out) = count(instances with weather=sunny and class=go-out) / count(instances with class=go-out) P(weather=sunny|class=stay-home) = count(instances with weather=sunny and class=stay-home) / count(instances with class=stay-home) P(weather=rainy|class=go-out) = count(instances with weather=rainy and class=go-out) / count(instances with class=go-out) P(weather=rainy|class=stay-home) = count(instances with weather=rainy and class=stay-home) / count(instances with class=stay-home) 3/31/2020 Shivani Saluja 10