Implement naive Bayes classifier