← अकादमी पर लौटें
At a radio desk, two adults consider a photo of a football on a frosty pitch beside trays marked with a ball and a cloud.
AI ज्ञानमुख्य10 नव॰ 2026· 3 मिनट

Naive Bayes for Document Classification

Naive Bayes classifies short notes by multiplying a topic's prior probability by each word's conditional probability. Smoothing keeps unseen vocabulary words from zeroing the score, while the independence assumption remains a deliberate simplification worth examining.

naive-bayestext-classificationprobability-smoothing

स्रोत

पूरा पाठ सारांश

A school noticeboard carries two kinds of short notes. Sports notes say things like "match moved to field two, bring boots." Weather notes say "frost expected, cover the seedlings." A Naive Bayes classifier learns to sort new notes into such categories by counting words. It begins with a prior, the share of training notes in each category. If 60 of 100 notes were sports notes, the prior for sports is 0.6. That prior is then multiplied by conditional word evidence, the probability of each word given the category.

Suppose "field" appears 30 times among the 600 total word tokens in sports notes, but only 6 times among the 400 tokens in weather notes. Its conditional probabilities are 30/600 = 0.05 and 6/400 = 0.015. The bag-of-words representation ignores order and grammar, keeping only counts. For a new note, the classifier multiplies the prior by the conditional probability of every word, often using logarithms to avoid tiny numbers. A note reading "field frost" scores 0.6 × 0.05 × P(frost | sports) for sports and 0.4 × 0.015 × P(frost | weather) for weather. The higher product wins.

The interpretation is comparative. The score is not a calibrated certainty but a ranking device built from relative frequencies. The naive part is the conditional independence approximation. The model treats each word as if drawn independently once the category is known. Real notes cluster words, so "field" and "boots" travel together. Independence is an approximation, not a claim that words are uncorrelated overall. Two words can be strongly associated across the whole corpus and still be treated as separate evidence within each category.

Smoothing handles words absent from a category's training notes. Without it, one unseen vocabulary word gives a conditional probability of zero and erases the whole product. Additive smoothing adds a small count α to every word, then divides by the category's total word count plus α times the vocabulary size. With α = 1, called Laplace smoothing, a word seen zero times in sports notes with 600 total tokens and a 500-word vocabulary gets 1/(600+500) = 1/1100 ≈ 0.00091. Smoothing softens ignorance but does not create knowledge.

A mixed-topic sentence makes the limits visible. "Frost delayed the match, so bring boots" contains weather words and sports words. The classifier adds evidence from both and returns whichever category accumulates more. It cannot express "weather caused a sports cancellation" because the bag of words discards that structure. Nor can it weigh the word "delayed" differently from "frost." Each token contributes its own factor, so a repeated word also counts twice.

In a language or computing lesson, pairs tally word counts from eight composed sports and weather notes, compute smoothed probabilities with α = 1, and score a mixed note on a poster for class comparison. Have each pair write the multiplication on a poster and mark which word contributed most. Comparing posters lets students see how different smoothing choices or counting errors change the ranking, and disagreement about the mixed note opens a precise discussion of what the independence assumption ignores.