8 Using probability to its maximum: The naive Bayes model

 

This chapter covers

  • What is Bayes theorem?
  • Dependent and independent events.
  • The prior and posterior probabilities.
  • Calculating conditional probabilities based on events.
  • What is the naive Bayes model?
  • Using the naive Bayes model to predict if an email is spam or ham, based on the words in the email.
  • Coding the naive Bayes algorithm in Python.

Naive Bayes is a very important machine learning model used for prediction. The naive Bayes model is a purely probabilistic classification model, which means the prediction is a number between 0 and 1, indicating the probability that a label is positive. The main component of the naive Bayes model is Bayes theorem.

8.1    Sick or healthy? A story with Bayes theorem as the hero

8.1.1   Prelude to Bayes theorem: The prior, the event, and the posterior

8.2    Use-case: Spam detection model

8.2.1   Finding the prior: The probability that any email is spam

8.2.2   Finding the posterior: The probability that an email is spam knowing that it contains a particular word

8.2.3   What the math just happened? Turning ratios into probabilities

8.2.4   What about two words? The naive Bayes algorithm

8.2.5   What about more than two words?

8.3    Building a spam detection model with real data

8.3.1   Data preprocessing

8.3.2   Finding the priors

8.3.3   Finding the posteriors with Bayes theorem

8.3.4   Implementing the naive Bayes algorithm

8.3.5   Further work

8.4    Summary

8.5    Exercises

8.5.1   Exercise 8.1

8.5.2   Exercise 8.2

8.5.3   Exercise 8.3

sitemap