Naive Bayes
Explore the theory behind Naive Bayes classifiers by understanding Bayes theorem and its assumptions. Learn to implement Gaussian Naive Bayes in Python using Scikit-Learn, including example applications like disease prediction and spam filtering. Understand model advantages, code setup, and evaluation to apply this simple probabilistic classifier effectively.
We'll cover the following...
In Machine Learning, Naive Bayes classifiers are a family of simple “probabilistic classifiers”. They are based on applying Bayes’ theorem with strong independence assumptions between the features.
Before we begin to code, let’s learn some theory about Bayes’ theorem.
Bayes’ Theorem
Before we talk more about this classifier and try to code it, we should spend some time on what Bayes’s theorem is.
Bayes’ theorem (alternatively Bayes theorem, Bayes law, or Bayes rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event.
For example, the historical data shows us that everyone has a probability of 10% to get disease A, which is . Among the patients in this hospital, they will have probability to have symptom B. Meanwhile, patients with disease A with symptom B is 0.1, which is . Bayes’ theorem is used to find out when you have symptom B, what is the probability that you will get disease A? Just follow the formula below, you can get .
...