Intelligent Systems II · TEE · papers
Q4(b) Naive Bayes: job offer [10]
Re-examination · 31 Jan 2026
Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)
Question. Predict whether a candidate accepts a job offer from Experience (Fresher/Mid/Senior), Expected Salary (Low/Medium/High) and Company Reputation (Good/Average). Data: (Fresher, Low, Good, Yes), (Mid, High, Good, Yes), (Senior, High, Average, No), (Fresher, Medium, Average, Yes), (Senior, Low, Good, No), (Mid, Medium, Good, Yes), (Fresher, High, Average, No), (Senior, Medium, Average, No). New candidate: Mid, Low, Good. [10 marks]
Answer
Given
The full training data are in Step 1. Query: Experience=Mid, Salary=Low, Reputation=Good. The main calculation uses unsmoothed counts.
To find
Both class scores and the predicted class.
Formula and why it applies
score(C)=P(C)\prod_jP(a_j\mid C)C is a class label. Each aⱼ is one query feature value. First count inside a class, then multiply the prior and all three likelihoods.
Solution
Step 1. Write the training rows as a table
| Row | Experience | Salary | Reputation | Class |
|---|---|---|---|---|
| 1 | Fresher | Low | Good | Yes |
| 2 | Mid | High | Good | Yes |
| 3 | Senior | High | Average | No |
| 4 | Fresher | Medium | Average | Yes |
| 5 | Senior | Low | Good | No |
| 6 | Mid | Medium | Good | Yes |
| 7 | Fresher | High | Average | No |
| 8 | Senior | Medium | Average | No |
Step 2. Separate the two class groups
| Class | Rows in this group | Class count | Prior |
|---|---|---|---|
| Yes | 1, 2, 4, 6 | 4 | 4/8 = 0.5 |
| No | 3, 5, 7, 8 | 4 | 4/8 = 0.5 |
Step 3. For class Yes, count Experience=Mid
Look only at class Yes rows 1, 2, 4, 6. The matching rows are 2, 6.
P(\text{Experience}=\text{Mid}\mid C=\text{Yes})=\frac{2}{4}=0.5Step 4. For class Yes, count Salary=Low
Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1.
P(\text{Salary}=\text{Low}\mid C=\text{Yes})=\frac{1}{4}=0.25Step 5. For class Yes, count Reputation=Good
Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1, 2, 6.
P(\text{Reputation}=\text{Good}\mid C=\text{Yes})=\frac{3}{4}=0.75Step 6. Multiply the Yes score one factor at a time
P(Yes)=4/8=0.50.5\times0.5=0.250.25\times0.25=0.06250.0625\times0.75=0.046875Step 7. For class No, count Experience=Mid
Look only at class No rows 3, 5, 7, 8. No row in this class has that feature value.
P(\text{Experience}=\text{Mid}\mid C=\text{No})=\frac{0}{4}=0Step 8. For class No, count Salary=Low
Look only at class No rows 3, 5, 7, 8. The matching rows are 5.
P(\text{Salary}=\text{Low}\mid C=\text{No})=\frac{1}{4}=0.25Step 9. For class No, count Reputation=Good
Look only at class No rows 3, 5, 7, 8. The matching rows are 5.
P(\text{Reputation}=\text{Good}\mid C=\text{No})=\frac{1}{4}=0.25Step 10. Multiply the No score one factor at a time
P(No)=4/8=0.50.5\times0=00\times0.25=00\times0.25=0Step 11. Compare the scores
score(Yes)=0.046875\qquad score(No)=0The larger score belongs to Yes. Normalise only if a posterior probability is requested: divide each score by their total 0.046875.
Yaad rakho: Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.