The principle of machine learning algorithm and the naïve Bayesian classification of programming practice

Source: Internet
Author: User

Before introducing naive Bayesian classification, we first introduce the Bayesian theorem that we all know better, that is, the probability of knowing a certain conditional probability, how to get two time exchange probabilities,

That is, in the known P (a| B) In the case of how to obtain P (b| A)? Can be obtained by the following formula:

Naive Bayesian classification is a simple classification algorithm, which is called simplicity because of its simplicity: in terms of text categorization, it believes that the relationship between 22 words in a word bag

Are independent of each other, that is, each dimension in the eigenvector of an object is independent of each other.

The formal definition of Naive Bayes classification is as follows:

(1) Set as one of the items to be categorized, and each A is a characteristic attribute of x.

(2) There is a category collection.

(3) calculation.

(4) If, then.

Therefore, the key to the problem now is how to calculate each conditional probability in step (3). We can calculate the following steps.

(1) Find a known classification of the set of items to be categorized, that is, the training set.

(2) The conditional probability estimation of each characteristic attribute under various types is obtained by statistic. That

(3) If each characteristic attribute is conditionally independent (or if they are independent of each other), then the Bayesian theorem is deduced as follows:

Because the denominator is the same for all categories, it is constant, so just maximize the numerator. And because a feature attribute is conditionally independent, there are

This is the description of the formula derivation process in Scikit-learn. According to the above analysis, the naïve Bayesian classification process can be expressed as follows:

First stage: Training data Generation Training Sample set: TF-IDF

Second stage: Calculate for each category.

Phase Three: Calculates the conditional probabilities of all categories for each feature attribute.

Phase IV: Calculation for each category.

Fifth stage: The largest item to be the category of X.

The principle of machine learning algorithm and the naïve Bayesian classification of programming practice

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.