---
title: "Naive Bayes and Laplacian correction"
subject: "Data Mining"
chapter: 3
key: "semester_7/data_mining:naive-bayes-laplace"
source: https://www.bctengineer.com/q/semester_7/data_mining/naive-bayes-laplace
site: BCT Engineering
---

# Naive Bayes and Laplacian correction

Data Mining · Chapter 3: Classification

- Asked in: year not given
- Video: [Lec-8: Naive Bayes Classification Full Explanation with examples | Supervised Learning](https://www.youtube.com/watch?v=GBMMtXRiQX0) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/data_mining/naive-bayes-laplace
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-3

## Question

Describe Naïve Bayes Classifier. Why is it "Naïve"? Explain Laplacian Correction for zero-probability Problem.

## Short answer

Naïve Bayes uses Bayes theorem with the class-conditional independence assumption, which is often unrealistic, hence 'naïve.' Laplacian correction adds 1 to counts to avoid zero probabilities when a value never appears with a class.

## Answer

The **Naïve Bayes classifier** is a statistical classifier based on **Bayes' theorem**. It predicts the probability that a tuple belongs to each class and assigns the class with the highest posterior probability.

#### Bayes' theorem
P(C | X) = P(X | C) · P(C) / P(X)

For a tuple X = (x₁, …, xₙ) and classes C₁ … C_m, X is assigned to the class Cᵢ that maximises P(X | Cᵢ)·P(Cᵢ) (P(X) is the same for all classes and is ignored).

- P(Cᵢ) = (number of training tuples of class Cᵢ)/(total tuples).
- For categorical attributes, P(xₖ | Cᵢ) = (tuples of class Cᵢ having value xₖ)/(tuples of class Cᵢ).
- For continuous attributes a Gaussian density with the class mean and standard deviation is used.

*Example*: buys-computer data (9 yes, 5 no), X = (young, income low, student yes, credit fair): P(X | yes)P(yes) = (2/9)(3/9)(6/9)(6/9)(9/14) = 0.0212; P(X | no)P(no) = (3/5)(1/5)(1/5)(2/5)(5/14) = 0.0034. So class = yes.

#### Why "naïve"?
It makes the simplifying assumption of **class-conditional independence**: given the class, the attributes are assumed independent of each other, so P(X | C) = Π P(xₖ | C). This is rarely true in real data (e.g. age and income are related), yet it makes computation easy and often still gives good accuracy.

#### Laplacian correction (Laplace smoothing)
If some attribute value never occurs with a class in the training data, P(xₖ | C) = 0 and the whole product becomes 0, whatever the other attributes say. To avoid this **zero-probability problem**, add 1 to each count (assume each value has at least one extra tuple):

P(xₖ | C) = (nₖ + 1) / (n_C + v)

where nₖ is the count of value xₖ in class C, n_C is the number of tuples of class C and v is the number of distinct values of the attribute.

*Example*: in a class of 1000 tuples, income has low = 0, medium = 990, high = 10. Corrected: low = 1/1003, medium = 991/1003, high = 11/1003. The corrected values are close to the old ones, but are never zero.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which class does Naive Bayes assign?
   A. The class with highest P(X)
   B. The class with fewest tuples
   C. The class maximising P(X|Ci)P(Ci)
   D. The class with the lowest posterior
   Answer: C. P(X) is the same for all classes and is ignored. (Key point: Decision rule)

2. Why is it called 'naive'?
   A. It assumes attributes are independent given the class
   B. It ignores the class prior
   C. It uses only one attribute
   D. It cannot compute probabilities
   Answer: A. Class-conditional independence gives P(X|C) = product of P(xk|C). (Key point: Why naive)

3. What problem does a zero count cause?
   A. The prior becomes 1
   B. The whole product becomes 0 regardless of other attributes
   C. The class is ignored in training
   D. P(X) becomes negative
   Answer: B. One zero factor wipes out the product. (Key point: Zero probability)

4. Laplacian correction uses P(xk|C) =
   A. (nk + 1)/nC
   B. nk/(nC + v)
   C. (nk + v)/(nC + 1)
   D. (nk + 1)/(nC + v)
   Answer: D. 1 is added to each of the v value counts, so the denominator grows by v. (Key point: Laplace formula)

## Related in Data Mining

- [Naive Bayes advantages and disadvantages](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Anaive-bayes-pros-cons) — Data Mining, chapter 3
- [Buys computer: ID3 and Naive Bayes](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Abuys-computer-id3-naive-bayes) — Data Mining, chapter 3
- [Play golf: ID3 and Naive Bayes](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aplay-golf-id3-naive-bayes) — Data Mining, chapter 3

## Related in other subjects

- [Causal net, belief network, Bayes](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Acausal-net-belief-network) — Artificial Intelligence, chapter 4, asked 2×
- [Mutually exclusive vs equally likely; Bayes topper](https://www.bctengineer.com/question.md?key=semester_5%2Fprobability_and_statistics%3Abayes-top-student-electronics) — Probability and Statistics, chapter 1
