Description
-
Create text file for the following data and load data through Pandas libraries
-
Build your own Naïve Bayes classifier model using steps below
-
Class: P(C) = Nc/N
-
e.g., P(No) = 7/10,
-
For discrete attributes:
P(Ai | Ck) = |Aik|/ Nck
where |Aik| is number of instances having attribute Ai and belongs to class Ck
Examples:
P(Status=Married|No) = 4/7
P(Refund=Yes|Yes)=0
• |
Normal distribution: |
categoricalcategorical continuous class |
||||||||
2 ij2 |
||||||||||
One for each (Ai,ci) pair |
||||||||||
( A |
)2 |
|||||||||
1 |
iij |
|||||||||
P( Ai | c j ) |
e |
2 ij2 |
||||||||
For (Income, Class=No): |
Tid |
Refund |
Marital |
Taxable |
Evade |
|||||
Status |
Income |
|||||||||
If Class=No |
||||||||||
sample mean = 110 |
1 |
Yes |
Single |
125K |
No |
|||||
sample variance = 2975 |
2 |
No |
Married |
100K |
No |
|||||
• Once Trained, test your model for the |
3 |
No |
Single |
70K |
No |
|||||
cases below |
4 |
Yes |
Married |
120K |
No |
|||||
X1 = {Refund = Yes, Status = Divorced, |
5 |
No |
Divorced |
95K |
Yes |
|||||
Income = 90K, Evade = ?} |
6 |
No |
Married |
60K |
No |
|||||
X2 = {Refund = No, Status = Married, |
7 |
Yes |
Divorced |
220K |
No |
|||||
Income = 60K, Evade = ?} |
||||||||||
8 |
No |
Single |
85K |
Yes |
||||||
9 |
No |
Married |
75K |
No |
||||||
10 |
No |
Single |
90K |
Yes |