Python implementation of Naive Bayes algorithm