Algorithm Description:
Input: Training data $t={(X_{1},y_{1}), (X_{2},y_{2}),..., (X_{n},y_{n})}$, where $x_{i}= (x_{i}^{(1)},x_{i}^{(2)},..., x_{i}^{(N)}) $ , $x _{i}^{(j)}$ is the J-feature of the sample I, $x _{i}^{(j)}\in \{a_{j1},a_{j2},..., A_{js} \}$, $a _{jl}$ represents the possible L-values of the J-Features, j=1,2,..., n,l= ,..., Sj, $y _{i} \in \{c_{1},c_{2},..., c_{k} \}$; instance x;
Output: Classification of Instance X
(1) Calculate prior probability and conditional probability
$P (Y=c_{k}) =\frac{\sum_{i=1}^{n}i (Y_{i}=c_{k})}{n},k=1,2,..., k$
$P (x^{(j)}=a_{jl}| Y=c_{k}) =\frac{\sum_{i=1}^{n}i (x_{i}^{(j)}=a_{jl},y_{i}=c_{k})}{\sum_{i=1}^{n}i (Y_{i}=c_{k})},$
$j =1,2,..., n;l=1,2,..., s_{j};k=1,2,..., k$
(2) for a given instance $x= (x^{(1)},x^{(2)},..., x^{(n)}) ^{t}$, COMPUTE
$P (Y=c_{k}) \prod_{j=1}^{n} P (x^{(j)}=x^{(j)}| Y=c_{k}), k=1,2,..., k$
(3) Determine the category of instance X
$y =arg \max_{c_{k}}p (Y=c_{k}) \prod_{j=1}^{n}p (x^{(j)}=x^{(j)}| Y=C_{K}) $
Naive Bayesian algorithm notes