functions from naive bayes classifier