Bayesian classification algorithm

Source: Internet
Author: User

Classification is actually according to a certain standard to label objects, and then according to the label, Bayesian classification algorithm based on probability statistics is the most common classification algorithm, is also the most widely used in the field of garbage text recognition algorithm.

Using the Bayesian classification algorithm for the two classification can be broadly divided into the following steps:

    1. Collect a large amount of garbage content and non-spam corpus, set up the training of garbage corpus and normal content corpus.
    2. The corpus text is segmented, the independent string is extracted, and the frequency of the occurrence of the string in the text is counted.
    3. Each training corpus corresponds to a hash table, for example, the garbage corpus is placed in the Hashtable_bad, rather than the garbage corpus in the Hashtable_good, while the Hashtable stores the string extracted by the word and the corresponding frequency.
    4. Calculates the probability that all hashtable strings appear, that is, the total number of Word/string of the p= string.
    5. Combining Hashtable_good and Hashtable_bad, it is speculated that when a string of text contains a character, the text is the probability of garbage content, the corresponding mathematical expression is as follows: P (A|ki) = Pbad (ki)/[Pgood (ki) +pbad (ki)], Where event A indicates that the text is spam, k1,k2 ... kn represents the extracted keyword, and P (A|ki) indicates that the text is the probability of spam, Pbad (ki) is the value of TI in Hashtable_bad when the Keyword Ki appears in the text. and Pgood (KI) is the value of Ki in Hashtable_good.
    6. Establishes a new hashtable_probability storage string Ki to P (a|ki) mapping.

At this point, the Bayesian classification of the training and learning process is completed, the next can be based on hashtable_probability to calculate the possibility of the text as garbage content. Assume that the user submitted text content through word segmentation to get n keyword k1,k2,k3......kn,hashtable_probability corresponding to the value of P1,P2 ... Pn, P (a|k1,k2,k3......kn) indicates that when the keyword K1,K2,K3......KN is present in a user-submitted text, the content is the probability of the spam text, p (a|k1,k2,k3......kn) =p1*p2* ... Pn. When P (A|K1,K2,K3......KN) exceeds the predetermined threshold, it can be judged that the content is spam, and by adjusting the threshold, you can control how harsh the anti-spam system is for content filtering.

Bayesian classification algorithm

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.