Naive Bayes classifier implementation