Posts

Showing posts from November, 2018

Naïve Bayes with Python

Image
Introduction The Naive Bayes algorithm is based on conditional probabilities. It uses Bayes' Theorem , a formula that calculates a probability by counting the frequency of values and combinations of values in the historical data. Bayes' Theorem finds the probability of an event occurring given the probability of another event that has already occurred. If B represents the dependent event and A represents the prior event, Bayes' theorem can be stated as follows. To calculate the probability of B given A , the algorithm counts the number of cases where A and B occur together and divides it by the number of cases where A occurs alone. Implementation Scikit-learn provides implementation of Naïve Bayes algorithm of 3 flavors: MultinomialNB implementing the naive Bayes algorithm for multinomially distributed data ; GaussianNB implementing the Gaussian Naive Bayes algorithm for classification; and BernoulliNB implements the naive Bayes training and classificat