Public opinion theme mining and sentiment analysis and theme mining evaluation method

Through the theme mining and sentiment analysis methods of public opinion, neural network models and clustering algorithms are used to analyze public opinions on major engineering projects, solving the problems of insufficient data and narrow coverage in the existing technology, and achieving the entire life cycle of the project Effectively analyze and manage suggestions.

CN119128144APending Publication Date: 2024-12-13BEIJING JIAOTONG UNIV

Patent Information

Application Number
CN202411042400.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The existing technology has shortcomings in the research on public opinions and text mining throughout the life cycle of major engineering projects, and it is difficult to effectively collect and analyze public opinions data with a wide coverage and a large number of stakeholders, resulting in insufficient data and narrow coverage.

Method used

A method of public opinion theme mining and sentiment analysis, including data collection, noise clearance, text embedding, dimensionality reduction processing, theme clustering, keyword calculation and sentiment analysis, using pre-trained neural network models and UMAP, HDBSCN, TF- Algorithms such as IDF combine sentiment analysis models to conduct topic modeling and sentiment analysis to analyze the stage and regional public opinions and focus and trends of change in major engineering projects.

Benefits of technology

It has achieved the analysis of the focus and changing trends of the entire life cycle of public opinions on major engineering projects, provided a new management suggestions and evaluation perspective, helped to fully understand and manage projects, and improved the efficiency and effectiveness of the public opinion management system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119128144A_ABST
    Figure CN119128144A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of public sentiment analysis, and particularly relates to a public opinion theme mining and sentiment analysis and theme mining evaluation method. The invention provides a public opinion topic mining and sentiment analysis method, which comprises the following steps of: generating text embedding of a document by adopting a pre-trained neural network model Instructor-large, realizing dimensionality reduction and clustering of the text embedding by adopting a UMAP (Uniform Mode Access Point) combined with an HDBSCN (Hadoop Definition Broadcast Neural Network) algorithm, and performing keyword extraction on lexical elements in a topic cluster by using a TF-IDF (Term Frequency-Inverse Document Frequency) algorithm to obtain topic representation; according to the method, researchers can be helped to analyze staged and regional public opinion attention key points and change trends of the major engineering project by using theme modeling and sentiment analysis technologies, and provide management suggestions, so that a reference is provided for a major engineering project public opinion management system in an all-media era, and the important engineering project public opinion management system is provided. And a brand-new view angle is provided for comprehensively knowing and evaluating the project.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of public sentiment analysis, and specifically relates to a public opinion topic mining and sentiment analysis and a topic mining evaluation method. Background Art

[0002] From a practical point of view, cross-regional major engineering projects have the characteristics of wide impact, complex levels, long duration, many stakeholders, and huge construction costs. Such projects, whether it is feasibility study, construction drawing design or formal construction, construction and operation, require managers to conduct full and thorough feasibility demonstration at each stage. With the continuous development of information technology, the public is more and more inclined to express their opinions on major engineering projects that are closely related to their lives on the Internet.

[0003] The study of public opinion is common in the fields of sociology, legal system, psychology, behavioral science, etc., and can systematically analyze the public's views and opinions on a certain thing. The earliest study of public opinion in the engineering field can be traced back to 1972. Scholars used expert scoring, individual interviews and questionnaires, combined with a variety of theoretical tools to collect and analyze the public's opinions on engineering projects that are closely related to the public's daily life, such as water environment, nuclear power plants, waste recycling, and highways.

[0004] Traditional public opinion surveys have problems such as difficulty in data collection, small sample size, and narrow coverage. With the rapid development of the Internet in the information age, online platforms have become the main place for people to obtain information, establish connections, and express opinions.

[0005] Major engineering projects can promote the effective circulation of regional resources, optimize the layout of the industrial chain, create a large number of employment opportunities, and improve the quality of life of the public. They not only meet the current development needs of the country, but also meet and enrich the expectations of all sectors of society for high-quality development. Therefore, the public’s opinions on major engineering projects must be considered.

[0006] However, existing research on major engineering projects, public opinions and text mining at home and abroad still has the following shortcomings:

[0007] (1) Insufficient research on public opinion of major engineering projects. Although the academic community has gradually realized the importance of studying public opinion on major engineering projects, there is still little research on public opinion on major engineering projects. Most of the existing relevant literature focuses on public evaluation during the planning and operation stages of major engineering projects, and there is little research on public opinion throughout the life cycle of major engineering projects.

[0008] (2) The application of text mining technology in public opinion surveys needs to be strengthened. Traditional public opinion survey methods use field surveys, seminars, questionnaires, expert interviews and other methods to collect public opinions on major engineering projects. Affected by the number of samples and duration of the survey, the data collected by this type of method is difficult to reflect the characteristics of major engineering projects, such as long construction periods, wide coverage, and a large number of stakeholders. Although text mining technology is widely used in many disciplines, research on public opinion on major engineering projects is still very lacking. Summary of the invention

[0009] In view of the above-mentioned problems existing in the prior art, the purpose of the present invention is to provide a public opinion topic mining and sentiment analysis and a topic mining evaluation method, which can help researchers use topic modeling and sentiment analysis techniques to analyze the focus and changing trends of public opinion on major engineering projects at different stages and regions, and put forward management suggestions, thereby providing a reference for the public opinion management system of major engineering projects in the omnimedia era and providing a new perspective for comprehensively understanding and evaluating projects.

[0010] In order to solve the above problems, the technical solution adopted by the present invention is as follows: a method for public opinion topic mining and sentiment analysis, the method comprising the following steps:

[0011] S1: Collect public opinion data on the public platform, remove noise and clean the data, and classify it by time and space;

[0012] S2: Use the pre-trained neural network model to perform text embedding on the data classified in step S1 to generate a vector representation of the post;

[0013] S3: Use the UMAP algorithm to perform dimensionality reduction processing on the data after the text is embedded in step S2, and convert the high-dimensional vector into a low-dimensional feature vector;

[0014] S4: using the HDBSCN algorithm to cluster the low-dimensional space formed by the feature vectors obtained in step S3 to form a topic cluster representation;

[0015] S5: Using the TF-IDF algorithm to calculate the keywords representing the topic clusters after the clustering representation in step S4, sort and classify the topic clusters, and perform time evolution analysis and regional topic analysis on the topics;

[0016] S6: Randomly extract the public opinion and comment content collected in step S1 as a data set, establish a uie-senta-base sentiment model, and fine-tune the model through the data set, and select the model with the highest score in the test machine to save;

[0017] S7: Use the sentiment analysis pre-trained model to output the sentiment tendency of the comments, map the ID of the comment to the topic, obtain the sentiment tendency of the topic, and perform temporal sentiment analysis;

[0018] In step S2, the Instructor-large pre-trained model is used to embed the post text after data preprocessing to generate a vector encoding of the text;

[0019] In step S3, the high-dimensional vector representation is reduced in dimension using the UMAP technique, wherein three parameters are set, namely n_neighbors, n_components, and metric; n_neighbors determines the number of neighboring points considered by the UMAP algorithm when constructing the topological structure of high-dimensional data; n_components specifies the dimension of the data after dimensionality reduction; the metric parameter is used to define the metric for calculating the distance between data points;

[0020] In step S4, clustering is performed using the HDBSCN algorithm, wherein the min_cluster_size parameter and the metric parameter are set; min_cluster_size defines the minimum set of points that are considered as a cluster;

[0021] Then, the clustered documents are tokenized to decompose the text content into a list of tokens. The token lists of all documents under the topic cluster are weighted and the tokens of each topic cluster are sorted according to their weights.

[0022] In step S6, the extracted data set is manually labeled with emotions, and the data set is divided into a training set, a test set, and a validation set according to a preset ratio. The uie-senta-base emotion model is fine-tuned using the data set, and the fine-tuning parameters and values ​​include a learning_rate of 0.00001, a batch_size of 16, a max_seq_len of 512, a num_epochs of 40, a seed of 1000, a logging_steps of 10, and a valid_steps of 100; the model is verified and saved every two rounds.

[0023] A topic mining evaluation method based on the above-mentioned public opinion topic mining and sentiment analysis method, the method comprising a topic internal evaluation index and a topic inter-class evaluation index;

[0024] The internal evaluation index of the topic is a topic consistency evaluation that evaluates the quality of the topic by analyzing the co-occurrence relationship between words in the topic. The evaluation index of the topic consistency evaluation is point mutual information, which is an index that measures the ratio of the frequency of co-occurrence of two events to the product of their independent occurrence frequencies.

[0025] The point mutual information calculation process is as follows: select the top N words in each topic cluster, pair these N words in pairs, and obtain each pair of words (w i ,w j ), using the formula:

[0026]

[0027] Calculate the value of the point mutual information, where p(w i ,w j ) is the probability of two words appearing together, p(w i ) and p(w j ) is the probability of each of the two words appearing;

[0028] For each topic, the average value of the point mutual information of all possible word pairs is calculated, and this average value is regarded as the consistency score of the current topic. The average value of the consistency scores of all topics is calculated to obtain the topic consistency score of the entire model;

[0029] The inter-class evaluation index includes a DBI value for evaluating clustering quality based on the average distance of samples within a cluster and the distance between the center points of different clusters, and a DI value for evaluating clustering effect by calculating the ratio of the minimum distance between clusters to the maximum distance within a cluster. The smaller the DBI value, the better the clustering effect, and the larger the DI value, the better the clustering effect.

[0030] The calculation formula of the DBI value is:

[0031]

[0032] Where k is the number of clusters, σ i is the average distance of samples within the i-th cluster, c i is the center of the ith cluster, d(c i ,c j ) is the cluster center c i and c j The distance between

[0033] The calculation formula of the DI value is:

[0034] DI=min 1≤i≤ k{min( 1≤j≤k,i≠j ){δ(c i ,cj ) / max l≤i≤k (Δ(c l ))}};

[0035] Where k is the number of clusters, δ(c i ,c j ) is cluster c i and cluster c j The distance between them, Δ(c l ) is cluster c l The maximum distance between internal samples.

[0036] Compared with the prior art, the present invention has the following beneficial effects:

[0037] The present invention provides a method for public opinion topic mining and sentiment analysis, which can help researchers use topic modeling and sentiment analysis techniques to analyze the focus and changing trends of public opinion on major engineering projects at different stages and regions, and put forward management suggestions, thereby providing a reference for the public opinion management system of major engineering projects in the omnimedia era and providing a new perspective for comprehensively understanding and evaluating projects. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 Schematic diagram of the steps of the analysis method of the present invention;

[0039] Figure 2 Schematic diagram of the topic clustering results in this embodiment;

[0040] Figure 3 Schematic diagram of each round of sentiment analysis indicators in this embodiment;

[0041] Figure 4 is a graph of the “elbow rule” in this embodiment;

[0042] Figure 5 Schematic diagram of the LDA model perplexity and consistency curve in this embodiment;

[0043] Figure 6 This is a schematic diagram for visualizing and comparing the topic clustering in this embodiment. DETAILED DESCRIPTION

[0044] The present invention is further described below in conjunction with specific embodiments.

[0045] This example proposes a public opinion topic mining and sentiment analysis research experiment. Figure 1 As shown, the experimental plan includes four parts: data collection, data preprocessing, topic modeling and sentiment analysis, and results.

[0046] The specific method includes the following steps:

[0047] S1: Collect public opinion data on the public platform, mainly collect posts and comments, remove noise and clean the data, and classify them by time and space;

[0048] S2: Use a pre-trained neural network model to embed the post data and generate a vector representation of the post;

[0049] S3: Use the UMAP algorithm to reduce the dimensionality of text embedding and convert high-dimensional vectors into low-dimensional feature vectors;

[0050] S4: using the HDBSCN algorithm to perform clustering on the low-dimensional space formed by the feature vectors obtained in step S3 to form a topic clustering representation;

[0051] S5: Use the TF-IDF algorithm to cluster the topic clusters, calculate the keywords representing the topic clusters, sort and classify the topic clusters, and conduct time evolution analysis and regional topic analysis of the topics;

[0052] S6: Randomly extract the public opinion comments collected in step S1 as a data set, establish a uie-senta-base sentiment model, fine-tune the model through the data set, and select the model with the highest score in the test set to save;

[0053] S7: Use sentiment analysis and training model data to analyze the sentiment tendency of comments, map the comment post ID to the topic, obtain the sentiment tendency of the topic, and perform temporal sentiment analysis.

[0054] In step S1, the process of collecting data is to first use the Scrapy framework to write a web crawler to collect posts and comments from a certain platform. The start time of the crawler is August 5, 2011, and the end time is September 23, 2019. This Scrapy framework requires users to write the following main parts.

[0055] (1) Spider

[0056] In view of the characteristics of the platform, this embodiment builds a dedicated Spider to achieve the platform's long time span and large amount of data crawling, the process is as follows:

[0057] 1) Send a seed request. Use the platform search API interface to construct the search expression of this embodiment and obtain a seed response;

[0058] 2) Parse the seed response. After receiving the seed response, use regular expressions to parse the post links contained in the page. Concatenate the post links into URLs and send them to the Engine to obtain the post response.

[0059] 3) Parse the post response. After receiving the post response, use json to construct the response into json data and match the content to be collected by field.

[0060] 4) Use the post ID and the comment search expression to get the comment list for each post.

[0061] 5) Parse the comment response. Use json to construct the response into json data and match the content to be collected by field. If the max_id field is not zero, continue to splice the comment request page and execute steps 4) and 5).

[0062] (2) Utems

[0063] Items defines the data that the Spider module needs to retain and pass. By defining fields such as post id, post body, and publishing time, the crawled data can flow from the Spider to the pipeline module.

[0064] (3)Pipeline

[0065] The Pipeline module defines how data is saved and generally consists of three parts:

[0066] 1) Getting Started

[0067] This part defines the operations that the crawler code will perform when it starts executing. This embodiment uses a local MySQL server to store data, so a new server connection is created in this part through the pymysql module.

[0068] 2) Close

[0069] This section defines the actions that the crawler code will perform when it is closed. The MySQL server needs to close the connection after use to free up resources. Therefore, the established server connection is closed in this section.

[0070] 3) Data processing

[0071] This section defines how the crawler code performs data saving operations at runtime. First, issue a table creation instruction to MySQL, define the fields in the table and the field types. Then send the fields saved in each periodic item to the MySQL server, and finally submit the save instruction.

[0072] (4)Middlewares

[0073] The Middlewares module defines the tasks to be performed by the crawler framework during the startup, execution, and end phases. The platform uses cookies to verify user information, and the simulated cookie information needs to be entered and converted into a dictionary format in this module.

[0074] (5)Settings

[0075] The Settings module defines the various functions of the crawler framework. In this module, you can set the start and end time of the crawler, concurrent vertical beams, enable items, and download middleware.

[0076] Through the above operations, we finally collected 26,084 posts and 63,458 comments.

[0077] The data is then preprocessed. In this embodiment, Python modules such as re, zhconv and pandas are used to clean and classify the raw data.

[0078] (1) Traditional Chinese characters are converted to simplified Chinese characters. In order to better model the topic, the zhconv module is used to convert the traditional Chinese characters in the post to simplified Chinese characters.

[0079] (2) Removing noise data: The original data may contain some information that is similar to the keyword but completely inconsistent with the content, and some users may add keyword-related fields to their posts to make the advertisements they posted related to this embodiment.

[0080] (3) Data cleaning: Clean @users, #topics#, URLs, emoticons, etc.

[0081] The posts and comments with empty text after processing were deleted, and finally a total of 24,888 posts and 54,650 comments were retained after processing. Each document includes information such as posting ID, user ID, posting time, user nickname, content, user location, etc. The post texts after data preprocessing were classified according to time and space.

[0082] Then, in step S2, the Instrument-large pre-trained model is used to embed the post text after data preprocessing to generate the vector encoding of the text. The generated high-dimensional vectors are as follows: Figure 2 shown.

[0083] In step S3, the high-dimensional vector representation of the document is reduced in dimensionality using the UMAP technique, wherein three parameters need to be set, namely n_neighbors, n_components, and metric.

[0084] n_neighbors determines the number of neighboring points that the UMAP algorithm considers when constructing the topological structure of high-dimensional data; n_components specifies the dimension of the data after dimensionality reduction; the metric parameter is used to define the metric for calculating the distance between data points.

[0085] In step S4, clustering is performed using the HDBSCN algorithm, in which the min_cluster_size parameter and the metric parameter are set; min_cluster_size defines the minimum set of points that are considered as a cluster. In order to form an independent cluster, the number of points in the cluster must be at least the number specified by min_cluster_size. This parameter directly affects the granularity of the clustering, and larger values ​​will result in fewer but larger clusters, while smaller values ​​allow more but smaller clusters to exist. Through many experiments, it was found that in this scheme, the distinction between clusters is more obvious when min_cluster_size is set to 40. HDBSCN and UMAP have the same definition of the metric parameter, which has three setting methods: Euclidean distance, Manhattan distance, and cosine similarity. According to the analysis in the previous article, in this embodiment, the metric is set to cosine. It should be noted that HDBSCN sets the vector labels of outliers and noise values ​​to -1, and documents with a label of -1 should be discarded in the result analysis of the topic model. As Figure 2 As shown, HDBSCN can better identify clusters, clusters of different topics are expressed in different colors, discrete values ​​and noise values ​​are represented in gray, and outliers are not forced to belong to adjacent topic clusters.

[0086] Then, all documents are tokenized, and the microblog posts are decomposed into a list of tokens through the custom Jieba module. The token list of all documents under the topic cluster is weighted, and the tokens of each topic cluster are sorted by weight, and the first 10 tokens are taken as the representation of the topic model.

[0087] In step S6, in order to improve the accuracy of the PaddleNLP "uie-senta-base" deep learning sentiment analysis model, 1000 comments are randomly selected from the comment data of this embodiment as a data set for manual sentiment annotation, and the data set is divided into a training set, a test set, and a validation set according to the ratio of [0.8, 0.1, 0.1]. The model is fine-tuned using the locally constructed data set. The main parameters and values ​​of the fine-tuning include learning_rate of 0.00001, batch_size of 16, max_seq_len of 512, num_epochs of 40, seed of 1000, logging_steps of 10, and valid_steps of 100; the model is verified and saved every two rounds.

[0088] After 11 hours and 40 rounds of training, the model achieved the highest training result in the 20th round, as shown in Figure 3As shown in the figure, the precision, recall and F1 indicators reached 0.98, 0.98 and 0.98, respectively. The results have great advantages over previous similar sentiment analysis studies, indicating that the deep learning pre-training model used in this scheme can be applied to this emotion recognition project and can meet the requirements of social media data sentiment analysis in this project. The model can be saved and used for subsequent comment sentiment tendency classification tasks.

[0089] To verify the effectiveness of this method in text topic clustering, all post data collected in this embodiment are used as topic modeling datasets, and multiple topic mining techniques are further used to perform the same topic mining process, and the clustering results are evaluated using the same evaluation index. The following table lists all topic mining techniques used in this embodiment:

[0090]

[0091] Table 1 Topic mining techniques

[0092] Method ① is a classic topic clustering method, which uses the TF-IDF algorithm for text embedding, and further uses K-Means to cluster topics. Calculate the error variance of K-Means when the number of topics ranges from 1 to 50, and draw an elbow rule graph. The error variance is the sum of the squares of the distances from a sample point to its nearest cluster center. It is an indicator for evaluating clustering performance. When the number of clusters increases, the number of samples in each cluster may decrease, resulting in a decrease in error variance. However, after a certain point, the reduction in error variance brought about by increasing the number of clusters will no longer be significant. This point is like an elbow. In other words, when the slope of the curve reaches its maximum value, the optimal number of topics can be determined. Figure 4 As shown, combining experience and the elbow method, it can be determined that the optimal number of topics in this embodiment is 24.

[0093] The experimental process of method ① is as follows:

[0094] 1.1: Text embedding using TF-IDF algorithm

[0095] 1.2: Randomly select 22 data points as the initial centroid a

[0096] 1.3: While 1:

[0097] Assign the high-dimensional vectors of 26084 data to the nearest centroid a to form 22 topic clusters, and calculate the centroid b of each topic cluster

[0098] if a == b:

[0099] Stop the loop

[0100] else:

[0101] a=b

[0102] 1.4: Count the word frequency of each cluster, and take the top 10 words with the highest word frequency as the topic representation

[0103] Method ② is the most commonly used model in the field of topic mining, which is simple to operate and has strong scalability. The LDA topic mining model believes that a document can be composed of multiple topics, and each topic is composed of several words. When mining topics on Weibo documents, the LDA model will generate "document-topic" probability distribution and "topic-word" probability distribution.

[0104] When using the LDA topic model to calculate the topic distribution of posts on the Weibo platform, it is necessary to comprehensively determine the optimal number of topics based on the perplexity and consistency curves. Figure 5 The number of topics, perplexity, and consistency curves after the model is run are shown. As the number of topics increases, the perplexity decreases evenly, and the consistency shows a fluctuating downward trend. Combined with experience, it can be obtained that the optimal number of topics is 83.

[0105] The experimental process of method ② is as follows:

[0106] 2.1: Convert the document to Bag-of-Words model through Jieba word segmentation

[0107] 2.2: Determine the number of topics K = 83

[0108] 2.3: Initialize the topic distribution of each word

[0109] 2.4: While 1:

[0110] For each token of each post, calculate the probability that it belongs to each topic

[0111] Update topic distribution of terms and documents

[0112] if convergence:

[0113] Stop the loop

[0114] 2.5: Take the top 10 words with the highest probability in each cluster as the topic representation

[0115] Method ③ is an improved model of LDA. It introduces the Sentence-Bert pre-trained language model for text embedding to obtain the local representation of the post. The optimal number of topics and the global document distribution representation of each post are obtained through the LDA model. The local representation and the global representation are concatenated into the feature vector of the post. The feature vector obtained in this way contains the local information of the post and the global distribution information of the topic, which further improves the text embedding effect of the original LDA. Finally, the K-Means clustering algorithm is used for clustering to obtain topic clustering. Since the method of determining the number of topics in this algorithm is the same as that of method ②, the optimal number of topics for this method is 83.

[0116] The experimental process of method ③ is as follows:

[0117] 3.1: Convert the document to a bag-of-words model through Jieba segmentation

[0118] 3.2: Determine the number of topics K = 83

[0119] 3.3: Initialize the topic distribution of each word

[0120] 3.4: While 1:

[0121] For each token of each post, calculate the probability that it belongs to each topic

[0122] Update topic distribution of terms and documents

[0123] If convergence

[0124] Stop the loop

[0125] 3.5: Input the document into the Sentence-Bert model to generate a high-dimensional vector v

[0126] 3.6: Concatenate v and the topic probability distribution c of each document generated by the LDA topic model along the y-axis to generate a high-dimensional vector of shape [v:c]

[0127] 3.7: Randomly select 83 data points as the initial centroid a

[0128] 3.8: While 1:

[0129] Assign the high-dimensional vectors in [v:c] to the nearest centroid a to form 83 topic clusters

[0130] Calculate the centroid b of each topic cluster

[0131] if a==b:

[0132] Stop the loop

[0133] else:

[0134] a=b

[0135] 3.9: Count the TF-IDF values ​​of each clustered word, and take the top 10 words with the highest values ​​as the topic representation

[0136] Method ④ Convert documents into text embeddings through Doc2Vec. Doc2Vec is an extension of the Word2Vec idea, which converts documents into vectors of fixed length. It not only considers the contextual information of words, but also the order of words in the document. Before use, the Doc2Vec model needs to be trained using an unsupervised method. The training data is the post text of this experiment, and the model learns the intrinsic structure and representation of the document through training. After the training is completed, the model is imported to generate text embeddings, and then the high-dimensional document vectors are reduced one by one through UMAP, and clustering is performed using the HDBSCN algorithm.

[0137] The experimental process of method ④ is as follows:

[0138] 4.1: Tagging documents, building vocabulary, and initializing the model

[0139] 4.2: Training model, epoch is set to 100, learning rate is set to 0.0002

[0140] 4.3: After training is completed, save the model and load the trained model

[0141] 4.4: Convert the document into text embeddings using trained Doc2Vec

[0142] 4.5: Use UMAP to reduce the text embedding l to a five-dimensional feature vector l 1

[0143] 4.6: For the eigenvector l 1 Clustering using HDBSCN

[0144] 4.7: Count the TF-IDF values ​​of the words in each cluster, and take the top 10 words with the highest values ​​as the topic representation

[0145] Method ⑤ is similar to method ④ in terms of basic approach, the main change is that the text embedding method is changed from Doc2Vec to Bert model. In this solution, the Chinese Bert model "bert-base-chinese" is used for document embedding.

[0146] The experimental process of method ⑤ is as follows:

[0147] 5.1: Convert the document into text embedding l through bert-base-chinese

[0148] 5.2: Use UMAP to reduce the text embedding l to a five-dimensional feature vector l1

[0149] 5.3: For the feature vector l 1 Clustering using HDBSCN

[0150] 5.4: Count the TF-IDF values ​​of the words in each cluster, and take the top 10 words with the highest values ​​as the topic representation

[0151] Method ⑥ and method ④ have the same basic approach as method 5. The main changes are that the text embedding method is changed to the Instructor-large model, and the improved C-TF-IDF algorithm is used in the topic representation part.

[0152] The experimental process of method ⑥ is as follows:

[0153] 6.1: Convert the document into text embedding l through Instructor-large

[0154] 6.2: Use UMAP to reduce the text embedding l to a five-dimensional feature vector l 1

[0155] 6.3: For the eigenvector l 1 Clustering using HDBSCN

[0156] 6.4: Count the TF value of each word in each cluster and its corresponding global IDF value, and take the top 10 words with the highest values ​​as the topic representation.

[0157] The document clusters formed by the six experiments are visualized as follows: Figure 6 As shown in the figure, from the perspective of text embedding effect, the best are experiments ⑤ and ⑥. The text embeddings are dispersed in high-dimensional space, indicating that pre-trained models such as Bert and Instructor-large can perform text numerical conversion well; followed by experiments ①, ② and ③. The generated text embeddings are mostly concentrated in the center, which is not conducive to clustering. It should be noted that experiment ③ is an improved method of experiment ②. By using Sentence-Bert and LDA to jointly embed text, it can be seen from the figure that the representation ability of text features is improved compared with the bag-of-words model, but it still has great limitations. The worst is experiment ④. Most of the generated text embeddings are concentrated in the center, resulting in the inability of subsequent clustering algorithms to effectively identify the similarities and differences of feature vectors.

[0158] From the perspective of dimensionality reduction and clustering effects, the best are experiments ⑤ and ⑥. The clusters are tight, each cluster is clearly separated from other clusters, and outliers are excluded from the correct document clustering, which makes it easier for researchers to understand the content of each document cluster. The number of generated clusters is relatively abundant, which can reflect the characteristics of this research data with a long time span and many public opinions. The second is experiments ②, ③ and ④. Although the number of generated clusters is relatively abundant, a large number of clusters exist in the center of the space, so there are overlaps and inclusions. The worst is experiment ①, which generates fewer clusters and a large number of clusters exist in the center of the space, indicating that the algorithm has not recognized the characteristics of the document.

[0159] Therefore, the topic clustering achieved by the “Bert+UMAP+HDBSCN” and “Instructor-large+UMAP+HDBSCN” methods has the best effect among similar methods.

[0160] We compare the topic mining evaluation indicators of the above embodiments.

[0161] First, determine the internal evaluation index of the topic. The quality of the topic keywords is measured by calculating two indicators of topic consistency, U mass and C_V. Six experiments are calculated separately, and the results are shown in the following table:

[0162]

[0163] As can be seen from the above table, the topic clustering model adopted in this embodiment, namely the Instructor-large+UMAP+HDBSCN+C-TF-IDF method, has high calculated U Mass and C_V indicators, indicating that the method of clustering, dimensionality reduction, and topic representation of posts in this embodiment can achieve the topic mining task relatively well. Specifically, methods ①, ③, and ⑥ have the best results, but the number of topic clusters completed by method ① is small, which cannot reflect the characteristics of the data set. Next are methods ② and ④, but the number of topics generated by method ④ is only seven, which also cannot reflect the characteristics of the data set. The worst is method ③. Although the Sentence-Bert and LDA models are used to jointly embed text, dimensionality reduction is not performed. Due to the dimensionality disaster and sparsity, the clustering algorithm has poor clustering ability for high-dimensional vectors. At the same time, the K-Means clustering algorithm is not as effective as the HDBSCN algorithm, which leads to the worst effect of the topic consistency index among all methods.

[0164] Secondly, determine the inter-class evaluation index of the topic. The DBI and DI indicators reflect the spatial relationship of topic clustering. Through these two indicators, we can see the distance of the topic clusters generated by the topic model in space. The DBI and DI indicators of the six experiments are calculated respectively, and the results are shown in the following table:

[0165]

[0166] From the above table, we can see that the Instructor-large+UMAP+HDBSCN+C-TF-IDF method proposed in this embodiment has a smaller DBI and a larger DI value, which means that the distance between the topic clusters generated by this method is large, while the distance within the cluster is relatively small. Specifically, the results of method ⑤ and method ⑥ are the best, and a larger DI value is obtained when the DBI value is small. The second is method ①, method ② and method ④, and the worst is method ③, which means that there is an inclusion relationship between the topic clusters and the internal clusters are relatively loose.

[0167] In summary, this embodiment designs comparative experiments of six commonly used topic mining models, and uses multiple aspects such as topic clustering and topic mining evaluation indicators to evaluate the topic clustering and topic representation generated by the topic mining model, proving that this method has the best effect. The pre-trained neural network model Instructor-large is used to generate text embeddings for documents, and the UMAP combined with the HDBSCN algorithm is used to achieve dimensionality reduction and clustering of text embeddings. The TF-IDF algorithm is used to extract keywords from the words in the topic cluster to obtain the topic representation. This method obtains a large number of topics for the platform's post data set, the consistency of the topics is good, the interpretability of the topic representation is strong, and the distance between the topic clusters is large, the topic clusters are relatively compact, and good distinction between topics is achieved.

Claims

1. A method for public opinion topic mining and sentiment analysis, characterized in that: The method comprises the following steps: S1: Collect public opinion data on the public platform, remove noise and clean the data, and classify it by time and space; S2: Use the pre-trained neural network model to perform text embedding on the data classified in step S1 to generate a vector representation of the post; S3: Use the UMAP algorithm to perform dimensionality reduction processing on the data after the text is embedded in step S2, and convert the high-dimensional vector into a low-dimensional feature vector; S4: using the HDBSCN algorithm to cluster the low-dimensional space formed by the feature vectors obtained in step S3 to form a topic cluster representation; S5: Using the TF-IDF algorithm to calculate the keywords representing the topic clusters after the clustering representation in step S4, sort and classify the topic clusters, and perform time evolution analysis and regional topic analysis on the topics; S6: Randomly extract the public opinion comments collected in step S1 as a data set, establish a uie-senta-base sentiment model, and fine-tune the model through the data set, and select the model with the highest score in the test set to save; S7: Use the sentiment analysis pre-trained model to output the sentiment tendency of the comments, map the ID of the comment to the topic, obtain the sentiment tendency of the topic, and perform temporal sentiment analysis; In step S2, the Instructor-large pre-trained model is used to embed the post text after data preprocessing to generate a vector encoding of the text; In step S3, the high-dimensional vector representation is reduced in dimension using the UMAP technique, wherein three parameters are set, namely n_neighbors, n_components, and metric; n_neighbors determines the number of neighboring points considered by the UMAP algorithm when constructing the topological structure of high-dimensional data; n_components specifies the dimension of the data after dimensionality reduction; the metric parameter is used to define the metric for calculating the distance between data points; In step S4, clustering is performed using the HDBSCN algorithm, wherein the min_cluster_size parameter and the metric parameter are set; min_cluster_size defines the minimum set of points that are considered as a cluster; Then, the clustered documents are tokenized to decompose the text content into a list of tokens. The token lists of all documents under the topic cluster are weighted and the tokens of each topic cluster are sorted according to their weights. In step S6, the extracted data set is manually labeled with emotions, and the data set is divided into a training set, a test set, and a validation set according to a preset ratio. The uie-senta-base emotion model is fine-tuned using the data set, and the fine-tuning parameters and values ​​include a learning_rate of 0.00001, a batch_size of 16, a max_seq_len of 512, a num_epochs of 40, a seed of 1000, a logging_steps of 10, and a valid_steps of 100; the model is verified and saved every two rounds.

2. A topic mining and evaluation method according to the method for public opinion topic mining and sentiment analysis according to claim 1, characterized in that: The method includes intra-theme evaluation indicators and inter-theme class evaluation indicators; The internal evaluation index of the topic is a topic consistency evaluation that evaluates the quality of the topic by analyzing the co-occurrence relationship between words in the topic. The evaluation index of the topic consistency evaluation is point mutual information, which is an index that measures the ratio of the frequency of co-occurrence of two events to the product of their independent occurrence frequencies. The point mutual information calculation process is as follows: select the top N words in each topic cluster, pair these N words in pairs, and obtain each pair of words (w i ,w j ), using the formula: Calculate the value of the point mutual information, where p(w i ,w j ) is the probability of two words appearing together, p(w i ) and p(w j ) is the probability of each of the two words appearing; For each topic, the average value of the point mutual information of all possible word pairs is calculated, and this average value is regarded as the consistency score of the current topic. The average value of the consistency scores of all topics is calculated to obtain the topic consistency score of the entire model; The inter-class evaluation index includes a DBI value for evaluating clustering quality based on the average distance of samples within a cluster and the distance between the center points of different clusters, and a DI value for evaluating clustering effect by calculating the ratio of the minimum distance between clusters to the maximum distance within a cluster. The smaller the DBI value, the better the clustering effect, and the larger the DI value, the better the clustering effect. The calculation formula of the DBI value is: Where k is the number of clusters, σ i is the average distance of samples within the i-th cluster, c i is the center of the ith cluster, d(c i ,c j ) is the cluster center c i and c j The distance between The calculation formula of the DI value is: DI=min 1≤i≤k {minutes} 1≤j≤k,i≠j ){δ(c i ,c j ) / max l≤i≤k (Δ(c l ))}}; Where k is the number of clusters, δ(c i ,c j ) is cluster c i and cluster c j The distance between them, Δ(c l ) is cluster c l The maximum distance between internal samples.

Citation Information

Patent Citations

  • Online comment emotion mining method based on topic model

    CN110807315A

  • Theme modeling and sentiment analysis method and system based on deep learning

    CN118394944A

Cited By

  • Broadband rapid spectrum detection sensing method, device, equipment and storage medium

    CN120074712A

  • Jeans appearance emotion preference analysis method

    CN120561274A