Implements the Naive Bayes