Classifying a Patient Using Naive Bayes Probabilities
Problem Setup
Scenario:Determine whether a patient is likely to have a Viral or Healthy diagnosis from a set of observed symptoms.
Given:Ten historical patient records with Fever, Fatigue, Cough, and Headache observations, each paired with a known diagnosis.
Task:Apply categorical Naive Bayes without smoothing: calculate the class priors and conditional probabilities for a patient with High fever, Fatigue = Yes, Cough = Yes, and Headache = Yes, then compare the class scores to predict the diagnosis.
Need a quick refresher? Review Naive Bayes theory
Patient Symptoms & Diagnosis
Each record pairs four observed symptoms with a known diagnosis. These labeled observations provide the counts needed to establish the prior class probabilities and measure how frequently each symptom occurs within the Viral and Healthy groups.
| Data Point | Fever✎ | Fatigue✎ | Cough✎ | Headache✎ | Diagnosis |
|---|---|---|---|---|---|
| P1 | High | Yes | Yes | Yes | Viral |
| P2 | High | Yes | No | Yes | Viral |
| P3 | Normal | No | Yes | No | Healthy |
| P4 | Normal | No | No | No | Healthy |
| P5 | High | No | Yes | Yes | Viral |
| P6 | Normal | Yes | No | Yes | Healthy |
| P7 | High | Yes | Yes | No | Viral |
| P8 | Normal | No | Yes | Yes | Healthy |
| P9 | Normal | Yes | Yes | No | Healthy |
| P10 | High | Yes | No | No | Viral |
| Target | High | Yes | Yes | Yes | ? |
Step-by-Step Solution
Step 1: Calculate Prior Probabilities P (Class)
= 0.5
= 0.5
Step 2: Calculate Conditional Probabilities P (Feature | Class)
Step 3: Calculate Class Scores and Select the Prediction
= 5/10 * 5/5 * 4/5 * 3/5 * 3/5
= 0.144
= 5/10 * 0/5 * 2/5 * 3/5 * 2/5
= 0
Final Answer
Prediction:Viral
Fever = High has zero observed frequency in the Healthy class, making its unsmoothed class score zero. The Viral class receives a positive score, so it is selected. This prediction is based on the given training records and the Naive Bayes independence assumption.
Exam Takeaway
- Keep likelihoods class-specific: Calculate using only the training records belonging to class . The same feature value can have different conditional probabilities for different classes, so always check the denominator.
- Understand the zero-frequency problem: Without smoothing, a single zero conditional probability makes the entire class score zero. Laplace smoothing can prevent this by adding one to each category count and adjusting the denominator to include the number of possible categories.
- Distinguish class scores from posterior probabilities: Multiplying the prior by the feature likelihoods gives an unnormalized score. These scores are sufficient for choosing the most likely class, but they must be normalized before being interpreted as posterior probabilities.