The Naïve Bayes classifier

The Naive Bayes classifier technique is based on the Bayesian theorem and is appropriate when the dimensionality of the input is high. Although it appears to be very simple, it is technically better performed than the other classification methods.

(More information is available at http://scikit-learn.org/stable/modules/naive_bayes.html and http://sebastianraschka.com/Articles/2014_naive_bayes_1.html).

Let's take a look at the following example that shows objects in red and blue. As indicated, the objects shown in red represent the set of people who have breast cancer, and the objects shown in blue represent the set of people diagnosed positive for breast cancer. Our task is to be able to label any new data, which in this case is a new person as they emerge that is based on the existing structure or category of objects and identify the group or class that the new data or person belongs to.

In Bayesian, the prior probability is more inclined to be close to the pattern or behavior of how the objects are currently characterized. This is mainly due to the fact that the word prior is synonymous to previous experience here; therefore, if there is a greater percentage of red than blue objects, then this gives us an advantage in expecting that the predicted outcome should be higher for it to be red.

The method here is a combination of Naïve Bayes and the k-nearest neighbor algorithm. For a pure Naïve Bayes classification, we will discuss another example using TextBlob (http://textblob.readthedocs.org/en/dev/).

The following image visually shows a new person as unclassified yet:

The Naïve Bayes classifier

Using the prior probability of red and blue, you can calculate the posterior probability of x being red or blue, as shown in the following code:

The Naïve Bayes classifier

The new person is most likely to be classified as one who is diagnosed positive with breast cancer.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset