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