python code for naive Bayes from scratch