# Chapter 13 Bayesian Network Practice

2022-08-06 07:06:41

# 1.1 Derivation of Naive Bayes

Naive Bayes is a supervised learning algorithm that applies Bayes' theorem based on the naive assumption that "features are independent" (ie: the probability of one feature appearing is independent of other features).

For a given eigenvector, the probability of the class can be calculated according to BayerThe Sterling formula gets:

Use the naive independence assumption:

With a given sample, is a constant:

Therefore

# 1.2 Applications of Naive Bayes

Naive Bayesian algorithm is widely used in real life, such as text classification, spam classification, credit evaluation, phishing website detection and so on.

# 1.3 Naive Bayesian Classification

• Gaussian Naive Bayes——, use maximum likelihood estimation (MLE) for the parameters.
• Multinomial Distribution Naive Bayes - For each class , the parameter is , where is the number of features, with probability .The parameter The result of using maximum likelihood estimation is:, .Assuming the training set is T, then ,Among them, is called Laplace smoothing; It is called Lidstone smoothing.

# 2 Processing flow of text data

(1) Crawl data

(2) Segment the text, which can be divided into Chinese word segmentation and English word segmentation. English word segmentation can be done with spaces, and Chinese word segmentation can be done by jieba word segmentation. Refer to https://blog.csdn.net/qwertyuiop0208/articleMethod 1 of text feature extraction in /details/125251521.

(3) Data preprocessing (including data cleaning and correction, etc.) refer to https://blog.csdn.net/qwertyuiop0208/article/details/125926133

(4) Standardize the data

(5) Convert strings into vectors by feature extraction methods such as TF-IDF or Word2vec.

(6) Modeling and model evaluation with algorithms such as machine learning.

# 3 Use TF-IDF to get text features

If a word or phrase has a high probability of appearing in a certain article and rarely appears in other articles, it is considered that the word or phrase has a good ability to distinguish between categories and is suitable for classification.TF-IDF is used to evaluate the importance of a word to a document or one of the documents in a corpus.

For details, see: https://blog.csdn.net/qwertyuiop0208/article/details/125251521.

# 4 Use of Word2vec

The essence is to establish a 3-layer neural network, map all words into vectors of a certain length; take a certain window range as the shower of the current word, and estimate the words in the window.It contains two algorithms, skip-gram and CBOW. The biggest difference between them is that skip-gram predicts the words around the center word through the center word, while CBOW predicts the center word through the surrounding words.

https://chowdera.com/2022/218/202208060623123417.html