Implemented naive bayes algorithm