# Naive Bayes

> Canonical: https://skillalmanac.com/glossary/naive-bayes | Last verified: 2026-11-25 | Index status: index-eligible

Naive Bayes is a family of supervised classification algorithms that apply Bayes' theorem while assuming each feature is independent of the others given the class. The assumption is simplistic, which is why it is called naive.

Also called: naive Bayes classifier, naive Bayes algorithm, naive Bayes classification, multinomial naive Bayes.

## In plain language

Naive Bayes sorts things into categories, such as spam or not spam, using estimated probabilities. In a multinomial text classifier, word counts estimate word likelihoods for each category, usually with smoothing to handle unseen words. The classifier combines those likelihoods with the prior probability of each category and chooses the highest posterior. It assumes features are independent given the category, which is often unrealistic for writing. Other family members use different feature distributions. It is quick to fit, but its reported probabilities can be poorly calibrated; check them on suitable held-out data before treating them as chances.

## Technical definition

Naive Bayes applies Bayes' theorem to estimate P(class | features) from P(class) and the product of P(feature | class) terms, using the naive assumption that features are conditionally independent given the class. Each per-feature distribution is estimated separately as a one-dimensional distribution, which the scikit-learn guide says helps alleviate problems from the curse of dimensionality. Variants differ in the distribution assumed for each feature, such as Gaussian, multinomial and Bernoulli. The predicted class is the one with the highest posterior. The scikit-learn user guide says naive Bayes is known as a decent classifier but a bad estimator, so predict_proba outputs are not to be taken too seriously.

## How it shows up when you use agents

Naive Bayes is a classic method, not something a coding agent runs by itself. It appears when you ask Claude Code, Codex or Cursor to build a small text classifier, for example a spam or topic filter, and the agent reaches for a scikit-learn naive Bayes class because it needs little code and few settings. It belongs to the family of [supervised learning](/glossary/supervised-learning) methods, so it needs labelled examples. See [Classification](/glossary/classification) for the task it solves and [scikit-learn](/glossary/scikit-learn) for the library that implements it.

The inspected examples below cover data inspection and split hygiene rather than training this model. What breaks when the method is misunderstood is the reading of its output. A score near 1 from `predict_proba` is not automatically a calibrated chance, and a high accuracy figure means little if test rows leaked into training. Before you accept an agent's result, ask for the held-out score and check the split with a leakage check. A sensible next action is to compare it with a second method on the same split.

## Common confusions

- **Naive versus wrong.** The independence assumption is often violated in real-world data, as IBM says, yet the scikit-learn guide still calls the method a decent classifier. Classification can work well despite this violation, while probability estimates may be poor.
- **Classifier versus probability estimator.** The predicted class can be useful while the reported probabilities are not. Do not assume calibration; when the conditional-independence and distribution assumptions hold and probabilities are correctly estimated, its probabilities can be correct.
- **Naive Bayes versus Bayesian statistics.** It uses Bayes' theorem, but it is a specific supervised algorithm with a fixed independence assumption, not a general Bayesian approach.
- **Naive Bayes versus a large language model.** See [Large language model](/glossary/large-language-model) for comparison. Naive Bayes treats each feature as independent given the class.

## Worked examples in this catalogue

### [split-leakage-check](https://skillalmanac.com/skills/skill-almanac/split-leakage-check)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A JSON report that checks train, validation and test files for duplicates, shared groups, time leakage and label leakage.

Why it exercises the concept: This inspected skill checks selected split-file leakage signals before evaluation. It does not train Naive Bayes or establish that a score is trustworthy.

### [huggingface-datasets](https://skillalmanac.com/skills/huggingface/huggingface-datasets)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Metadata, rows, search and filters for a Hugging Face dataset, read through the Dataset Viewer API.

Why it exercises the concept: This dataset reader can show labelled rows before fitting a supervised classifier; it does not fit the classifier.

### [data-analysis-eda](https://skillalmanac.com/skills/skill-almanac/data-analysis-eda)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A fixed exploratory-analysis procedure and a CSV profiler, with findings kept descriptive, evidenced and caveated.

Why it exercises the concept: Profiling a table shows column types, gaps and spread that inform feature-distribution choices. This inspected profiler does not train a classifier.

## Related terms

- [Supervised learning](https://skillalmanac.com/glossary/supervised-learning.md)
- [Machine learning (ML)](https://skillalmanac.com/glossary/machine-learning.md)
- [Classification](https://skillalmanac.com/glossary/classification.md)
- [Sentiment analysis](https://skillalmanac.com/glossary/sentiment-analysis.md)
- [scikit-learn](https://skillalmanac.com/glossary/scikit-learn.md)

## Sources

- [1.9. Naive Bayes](https://scikit-learn.org/stable/modules/naive_bayes.html), scikit-learn (accessed 2026-11-24)
- [What are Naive Bayes classifiers?](https://www.ibm.com/think/topics/naive-bayes), IBM (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
