Study Vault Search notes, aliases and full text
Graph
ConceptDBISAI-written · not yet proofread

Laplace Smoothing

Also Additive Smoothing · Add-One Smoothing · Add-Epsilon Smoothing

Additive smoothing replaces the relative frequencies n_wc / n_c by (n_wc + α) / (n_c + α|V|) for some α > 0, so that every word gets a non-zero probability while the estimates stay a probability distribution.

Know these firstNaive Bayes Classifier

Formula#

Smoothing given probabilities (exam WS 19/20, Task 4.2). If only the learned pwcp_{wc} are available, add ε>0\varepsilon > 0 to each of them and renormalize per class:

pwc′=pwc+ε∑v∈V(pvc+ε)=pwc+ε1+ε⋅∣V∣.p'_{wc} = \frac{p_{wc} + \varepsilon}{\sum_{v \in V} (p_{vc} + \varepsilon)} = \frac{p_{wc} + \varepsilon}{1 + \varepsilon \cdot |V|}.

With pwc=nwc/ncp_{wc} = n_{wc}/n_c this is additive smoothing with α=ε⋅nc\alpha = \varepsilon \cdot n_c:

nwc/nc+ε1+ε∣V∣=nwc+εncnc+εnc∣V∣.\frac{n_{wc}/n_c + \varepsilon}{1 + \varepsilon |V|} = \frac{n_{wc} + \varepsilon n_c}{n_c + \varepsilon n_c |V|}.

Properties#

The three properties asked in exam WS 19/20, Task 4.2, hold for every α>0\alpha > 0 (resp. ε>0\varepsilon > 0):

  1. Non-zero: nwc+α≥α>0n_{wc} + \alpha \ge \alpha > 0, and the denominator is positive, so pwc>0p_{wc} > 0 for every word, also for unseen ones.
  2. Order preserved within a class: nwc<nvc  ⟺  nwc+α<nvc+αn_{wc} < n_{vc} \iff n_{wc} + \alpha < n_{vc} + \alpha, and dividing by the same positive number keeps the strict inequality.
  3. Still a distribution: ∑w∈V(nwc+α)=nc+α∣V∣\sum_{w \in V} (n_{wc} + \alpha) = n_c + \alpha |V|, so the pwcp_{wc} of each class sum to 11.

Further:

  • Why it is needed in Naive Bayes: a single word of dd that was never seen in class cc makes pwc=0p_{wc} = 0 and the whole score of cc zero; in log space log⁡0\log 0 is undefined.
  • Effect of α\alpha: α→0\alpha \to 0 gives the unsmoothed relative frequencies; α→∞\alpha \to \infty pushes every pwcp_{wc} towards the uniform 1/∣V∣1/|V|. Smoothing helps rare classes and short training sets most, where ncn_c is small compared to α∣V∣\alpha |V|.

Example#

Sources#

  • Not covered by a WS 25/26 lecture. Source: the former Information Retrieval exams.
  • Exam WS 19/20, Task 4.2 (not published) (smooth(pwc, eps) with the three properties)

Search

Type In
↑ ↓ move ↵ open ⇥ next section Ctrl↵ results page Prefix # to search text only