Please correct me if wrong, but the way I am seeing Naive Bayes, the code looks fine. i.e. p should be equal to number of a feature in all positive documents/ the number of all features in all positive documents.
NOT number of a feature in all positive documents/the number of positive documents
.
I tried to read it in below links and still thinking p,q to be divided by total number of all words in class A. not total number of documents. Don’t know why accuracy increased.
Although b
seems to be right to be updated to something like
b = np.log((y==1).sum()/(y==0).sum())