Updated naive bayes algorithm to work on local training data