5 Using probability to its maximum The naive Bayes algorithm
This chapter covers:
- What is Bayes theorem?
- When are events dependent of independent?
- The prior and the posterior probabilities.
- Calculating conditional probabilities based on events.
- What is the naive Bayes algorithm?
- Using the naive Bayes algorithm 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 algorithm used for prediction. As opposed to the previous algorithms you’ve learned in this book, such as the perceptron algorithm, in which the prediction is discrete (0 or 1), the naive Bayes algorithm is purely probabilistic. This means, the prediction is a number between 0 and 1, indicating the probability that a label is positive. The main component of naive Bayes is Bayes Theorem.
Bayes Theorem is a fundamental theorem in probability and statistics, and it helps us calculate probabilities. The more we know about a certain situation, the more accurate the probability is. For example, let’s say we want to find the probability that it will snow today. If we have no information of where we are and what time of the year it is, we can only come up with a vague estimate.