Intermediate Topic 21 of 51 AI & Machine Learning
Naive Bayes
Probabilistic classifier assuming feature independence.
How it works
Naive Bayes classifiers apply Bayes' theorem with the naive assumption that features are conditionally independent given the class, so the posterior is proportional to the class prior times the product of per-feature likelihoods. Variants include Gaussian for continuous features, multinomial for word counts and Bernoulli for binary features. Training only counts frequencies, making it extremely fast, and Laplace smoothing avoids zero probabilities for unseen feature values.
Step-by-step walkthrough
- Start with how common each class is.
- Estimate how likely each feature is in each class.
- Multiply them, assuming features are independent.
- Choose the class with the highest posterior.
- The assumption is naive but it works well for text such as spam.
Where it is used
Spam filtering, text and sentiment classification, document categorization and quick baselines for high-dimensional sparse data use naive Bayes, and it works with little training data.
Common pitfall
The independence assumption is usually false, so probability estimates are poorly calibrated even when classification is good. Correlated features get double counted. Zero counts need smoothing, and continuous features may not match the Gaussian assumption. Use it as a baseline, apply log probabilities to avoid underflow and calibrate outputs if probabilities matter.
Where it fits in the course
Naive Bayes is topic 21 of 51 in AI & Machine Learning, rated Intermediate. It follows Regularization. The next topic is Support Vector Machines.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the AI & Machine Learning quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the AI & Machine Learning quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Naive Bayes?
Where do people use Naive Bayes?
What is the most common mistake with Naive Bayes?
What should I learn before this topic?
How can I practice it?
Is Naive Bayes hard to learn?
How long does it take to learn Naive Bayes?
Which topics are related to Naive Bayes?
What should I study after Naive Bayes?
Related topics
- Regularization (AI & Machine Learning)
- Support Vector Machines (AI & Machine Learning)
- Loss Functions (AI & Machine Learning)
- Random Forests (AI & Machine Learning)
- Bayes' Theorem (Math for Computing)