Social media sentiment prediction algorithm based on text content and user profile
By employing a social media sentiment prediction algorithm based on text content and user profiles, and combining SKEP, linguistic statistical vocabulary, and LDA topic model with backpropagation neural network and T-LSTM network, the problem of inaccurate sentiment prediction in existing technologies is solved, and a high-accuracy prediction of future sentiment index is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- FUDAN UNIVERSITY
- Filing Date
- 2022-09-24
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies struggle to accurately predict social media sentiment indices, and most research focuses on sentiment classification rather than regression problems, resulting in a lack of highly accurate predictions of future sentiment indices.
This paper adopts a social media sentiment prediction algorithm based on text content and user profiles. It uses the SKEP algorithm to calculate the daily sentiment index, combines a linguistic statistical vocabulary and LDA topic model to extract word frequency and topic distribution features, performs feature dimensionality reduction through backpropagation neural network, and uses T-LSTM network for time series analysis. Finally, it uses the final backpropagation neural network to predict the future sentiment index.
It has achieved a high accuracy rate in predicting future social media sentiment indices, improving the precision and reliability of sentiment prediction.
Smart Images

Figure CN115630231B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of big data mining technology, specifically involving a social media sentiment prediction algorithm based on text content and user profiles. Background Technology
[0002] Sentiment analysis on social media is a common practice in public opinion research, and sentiment analysis itself is a crucial metric. Predicting sentiment indices helps organizations understand changes in public sentiment in a timely manner, which is essential for the continuous improvement of rapidly evolving and impactful management measures.
[0003] While there is considerable academic research on sentiment prediction, there is a lack of research on the prediction of sentiment indices. Most existing research uses historical sentiment indices to predict future targets other than the sentiment index itself, such as stock prices and deaths. The inventors, in their research on sentiment index prediction, discovered that current research on sentiment indices can only predict future states, i.e., classifying states according to the magnitude of the sentiment index (very positive, generally positive, neutral, generally negative, very negative), thus predicting a classification problem rather than a regression problem. Summary of the Invention
[0004] In view of the above, the purpose of this invention is to provide a social media sentiment prediction algorithm based on text content and user profiles that can predict specific future sentiment indices with high accuracy.
[0005] The social media sentiment prediction algorithm based on text content and user profiles proposed in this invention has the following overall process: Figure 1 As shown, the process includes: calculating the daily sentiment index using the SKEP[1] algorithm; performing lexical analysis using a linguistic statistical vocabulary to obtain the content tendency features of past texts (called word frequency features) at the word level; using the LDA topic model[2] to perform topic distribution statistics on texts published on the same day to obtain the content tendency features of past texts (called topic distribution features) at the topic level; inputting word frequency features and topic distribution features into a backpropagation neural network for feature extraction to obtain dimensionality-reduced text features; classifying users who published content on the same day according to a series of personal information to obtain historical profile features of people participating in social media discussions; defining quantity features as the number of Weibo posts in the previous few days and sentiment features as the daily sentiment index in the previous few days. Inputting all time series vector features (including text features (including word frequency features, topic distribution features), profile features, quantity features, and sentiment features) into a time-perceived long short-term memory network (T-LSTM)[3], and using the last hidden layer of the time-perceived long short-term memory network as the input of the final backpropagation neural network to obtain the social media sentiment index for the next day;
[0006] The specific steps are as follows:
[0007] Step 1: Clean the past social media texts; for the cleaned texts, calculate all daily sentiment indices using a model pre-trained with the SKEP algorithm.
[0008] Step 2: For the cleaned text, use a linguistic statistical vocabulary to perform word frequency statistics on texts published on the same day from the previous few days (usually 6-10 days, typically 7 days, the same below) to obtain the content trend characteristics of past texts at the word level; for the cleaned text, use an LDA topic model to perform topic distribution statistics on texts published on the same day from the previous few days to obtain the content trend characteristics of past texts at the topic level; input the word frequency features and topic distribution features into a backpropagation neural network for feature extraction to obtain dimensionality-reduced text features; classify users who published content on the same day from the previous few days according to a series of personal information to obtain the profile features of historical participants in social media discussions; and define the quantity feature as the number of microblogs from the previous few days, and the sentiment feature as the daily sentiment index from the previous few days;
[0009] Step 3: Combine all time series vector features obtained in Step 2 (including word frequency features, topic distribution features, population profile features, quantity features, and sentiment features) and input them into a Temporally Perceived Long Short-Term Memory (T-LSTM) network. Use the last hidden layer of the Temporally Perceived Long Short-Term Memory network as the input to the final backpropagation neural network to obtain the social media sentiment index for the next day.
[0010] In this invention, step 1 specifically includes:
[0011] Step 1-1: The data cleaning includes: removing all non-alphabetic characters, deleting all useless words, and deleting all missing lines;
[0012] Step 1-2: For the text that has been cleaned, the probability of the text being positive is obtained by using the SKEP algorithm [1] pre-trained model, and this probability is used as the sentiment index of the text; the sentiment index of the texts published on the same day is averaged to calculate all the daily sentiment indices.
[0013] In this invention, step 2 specifically includes:
[0014] Step 2-1: For the cleaned text, use a linguistic statistical lexicon to perform word frequency statistics on texts published on the same day, and obtain the content tendency characteristics of past texts at the word level;
[0015] Step 2-2: For the cleaned text, use the LDA topic model to perform topic distribution statistics on the texts published on the same day, and obtain the content trend characteristics of the past texts from the topic level.
[0016] Steps 2-3: Input the word frequency features and topic distribution features into a backpropagation neural network to extract features and obtain dimensionality-reduced text features;
[0017] Steps 2-4: Categorize users who posted content on the same day according to a series of personal information to obtain the profile characteristics of people who participated in discussions on a certain topic on social media in the past.
[0018] In this invention, step 3 specifically includes:
[0019] Step 3-1: Combine all time series vector features, quantitative features, and sentiment features obtained in Step 2 and input them into a long short-term memory network that perceives time.
[0020] Step 3-2: Use the last hidden layer of the Long Short-Term Memory network that perceives time as the input to the final backpropagation neural network to obtain the social media sentiment index for the next day.
[0021] The innovation of this invention lies in:
[0022] The model proposed in this invention (denoted as SentiT) predicts future indices based on past sentiment indices, adding the number of Weibo posts, user profiles, and Weibo content as features to enhance predictive capabilities. Quantitative features reflect the scale of public discussion on a particular topic. Sentiment features reflect the changing trend of the sentiment index. Profile features reflect the characteristics of users who followed a particular topic on that day. The Weibo content will be further processed by a text feature extractor. Since LIWC and LDA can uncover public attention at the word frequency and topic levels, this invention uses these two text mining tools in the text feature extractor, and then uses a backpropagation neural network to extract dimensionality-reduced text features.
[0023] Since public discussion on a topic on social media may not be a continuous process, and the interval between two discussions is not fixed, we use T-LSTM as a time series feature extractor to account for the impact of time intervals. Finally, we use a final backpropagation neural network to obtain the final prediction results. Attached Figure Description
[0024] Figure 1 This is a flowchart illustrating the overall process of the social media sentiment prediction algorithm based on text content and user profiles, as described in this invention.
[0025] Figure 2 This is a diagram of the model structure in the social media sentiment prediction algorithm based on text content and user profiles of this invention. Detailed Implementation
[0026] To make the above-mentioned objectives and innovations of this invention easier to understand, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0027] according to Figure 2 As shown, the SentiT model proposed in this invention consists of three modules: a text feature extractor, a time-series feature extractor, and a prediction layer. The text feature extractor extracts text features using LIWC tools and an LDA model, and uses a backpropagation neural network to reduce the dimensionality of the text features. The LDA model has seven topics, and the backpropagation neural network consists of two fully connected layers. Sentiment features, text features, quantity features, and user profile features are concatenated and then input into the time-series feature extractor to learn the time-series features. Since public discussion of a topic on social media may not be a continuous process, and the interval between two discussions is not fixed, this invention utilizes a T-LSTM that considers the influence of time intervals as the time-series feature extractor. The prediction layer is a final backpropagation neural network, which consists of one fully connected layer, used to obtain the final daily sentiment index prediction.
[0028] Step 1: Clean the past social media texts; for the cleaned texts, calculate all daily sentiment indices using a model pre-trained with the SKEP algorithm.
[0029] Step 1-1: The data cleaning includes: removing all non-alphabetic characters, deleting all useless words, and deleting all missing lines;
[0030] Steps 1-2: For the cleaned text, use the SKEP algorithm to pre-train the model ERNIE 1.0large to obtain the probability that the text is positive, and use this probability as the sentiment index of the text; average the sentiment indices of the texts published on the same day to calculate the daily sentiment index.
[0031] Step 2: For the cleaned text, use a linguistic statistical lexicon to perform word frequency statistics on texts published on the same day, obtaining the content trend characteristics of past texts at the word level; for the cleaned text, use a topic model to perform topic distribution statistics on texts published on the same day, obtaining the content trend characteristics of past texts at the topic level; input the word frequency features and topic distribution features into a backpropagation neural network for feature extraction to obtain dimensionality-reduced text features; classify users who published content on the same day according to a series of personal information to obtain the profile features of people who participated in discussions on a certain topic on social media in the past:
[0032] Step 2-1: For the cleaned text, use a linguistic statistical lexicon to perform word frequency statistics on texts published on the same day, and obtain the content tendency characteristics of past texts at the word level;
[0033] Step 2-2: For the cleaned text, use the LDA topic model to perform topic distribution statistics on the texts published on the same day, and obtain the content trend characteristics of the past texts from the topic level.
[0034] Steps 2-3: Input the word frequency features and topic distribution features into a backpropagation neural network to extract features and obtain dimensionality-reduced text features;
[0035] Steps 2-4: Categorize users who posted content on the same day according to a series of personal information to obtain the profile characteristics of people who participated in discussions on a certain topic on social media in the past.
[0036] This invention chooses to use the LIWC[4] dictionary for lexical analysis, which is a widely used lexical analysis method in social science and natural language processing. LIWC is a program that can analyze 80 word classes that are meaningful in social psychology and has a huge vocabulary. This invention considers the frequency of occurrence of seventeen word classes in each text as the tendency and feature of the content in the text, and finally incorporates them when training the model.
[0037] Step 3: Combine all the time series vector features obtained in Step 2 and input them into a Temporally Perceived Long Short-Term Memory (T-LSTM) network. Use the last hidden layer of the T-LSTM network as the input to the final backpropagation neural network to obtain the social media sentiment index for the next day.
[0038] Step 3-1: Input all the time series vector features obtained in Step 2 into a time-sensing long short-term memory network;
[0039] Step 3-2: Use the last hidden layer of the Long Short-Term Memory network (LSTM) for time perception as input to the final backpropagation neural network to obtain the social media sentiment index for the next day. During model training, this invention uses mean squared variance as the loss function, as shown in the following formula:
[0040]
[0041] Where s is the time step of the input feature, and x = (x1, x2, ... x... n ), x∈R n, representing the features of the input to the final backpropagation neural network, that is, the last hidden layer of the Long Short-Term Memory network that perceives time; y = (y1, y2, ... y n ), y∈(0,1), represents the actual daily sentiment index for that day; f(x,θ) is the model function, representing the predicted daily sentiment index output given x; θ is the model parameter.
[0042] This invention uses Weibo posts from ordinary users related to five topics from March 1, 2020 to December 1, 2021 as experimental subjects, and evaluates them using the algorithm of this invention. The statistics of the dataset are shown in Table 1 below:
[0043] Table 1
[0044] Dataset Topic A Topic B C topic Topic D E-topic quantity 9176 21962 12391 12239 4436
[0045] The machine configuration used in the experiment is shown in Table 2 below:
[0046] Table 2
[0047]
[0048] The learning rate was set to 0.001, the optimizer was Adam[5], the batch size was 1, and the selected time step was 7 days, that is, the sentiment index of the previous seven days and other features were used to predict the sentiment index of the next day. 80% of the data was used as the training set, 10% of the data was used as the validation set, and the remaining 10% was used as the test set. The evaluation criteria used were MAPE, MAE, and MSE, and the calculation formulas are as follows:
[0049]
[0050]
[0051]
[0052] in, It is a predicted value of the sentiment index, y i It is the true sentiment index, and N is the number of samples.
[0053] The final experimental results are shown in Table 3 below. The results demonstrate that, compared with Navie-1 (using the previous day's sentiment index directly as the prediction value), ARIMA (linear prediction method), Support Vector Machine (SVM), and Long Short-Term Recurrent Neural Network (LSTM), the SentiT model proposed in this invention achieves the best results in all three metrics. This shows that the method of this invention has superiority in predicting Weibo sentiment index.
[0054] Table 3
[0055]
[0056] References:
[0057] [1] Hao Tian, Can Gao, Xinyan Xiao, Hao Liu, Bolei He, Hua Wu, Haifeng Wang, Feng Wu. SKEP: Sentiment Knowledge Enhanced Pre-training for Sentiment Analysis. Proc. of ACL, 2020.
[0058] [2] David M. Blei, Andrew Y. Ng, Michael I. Jordan. Latent Dirichlet Allocation. Machine Learning Research, 2003, 3: 993–1022.
[0059] [3] Inci M. Baytas, Cao Xiao, Xi Zhang, Fei Wang, Anil K. Jain, Jiayu Zhou. Patient Subtyping via Time-Aware LSTM Networks. Proc. of KDD, 2017.
[0060] [4] James W. Pennebaker, Roger J Booth, and Martha E. Francis. Linguistic inquiry and word count: LIWC 2001. Mahway: Lawrence Erlbaum Associates, 2001, 71. 2001.
[0061] [5] Diederik P. Kingma and Jimmy Lei Ba. Adam: A method for stochastic optimization. Proc. of ICLR, 2015.
Claims
1. A social media sentiment prediction algorithm based on text content and user profiling, characterized in that, The specific steps are as follows: Step 1: data cleaning on past social media text; for the cleaned text, pre-train the model by SKEP algorithm to calculate all daily sentiment indexes; Step 2: for the cleaned text, use linguistic statistical word table to count the word frequency of the text published on the same day in the past 6-10 days to obtain the tendency features of the content in the past text from the word level, which is called word frequency feature; for the cleaned text, use topic model to count the topic distribution of the text published on the same day in the past 6-10 days to obtain the tendency features of the content in the past text from the topic level, which is called topic distribution feature; input the word frequency feature and the topic distribution feature into a back propagation neural network for feature extraction to obtain the reduced text features; classify the users who published the content on the same day in the past 6-10 days according to a series of personal information to obtain the historical portrait features of the people participating in the discussion of a certain topic on social media; and define the quantity feature as the number of microblogs in the past 6-10 days, and the emotion feature as the daily sentiment index in the past 6-10 days; Step 3: combine all the time series vector features obtained in step 2, including word frequency feature, topic distribution feature, crowd portrait feature, quantity feature and emotion feature, and input them into a perception time long short-term memory network (T-LSTM) to obtain the social media sentiment index of the next day; Step 1 specifically includes: Step 1-1: the data cleaning includes: removing all non-alphabetic characters, deleting all useless words, and deleting all missing lines; Step 1-2: for the cleaned text, obtain the probability that the text emotion is positive by pre-training the model by SKEP algorithm, and take this probability as the text emotion index; average the text emotion indexes published on the same day to calculate all daily sentiment indexes; Step 2 specifically includes: Step 2-1: for the cleaned text, use linguistic statistical word table to count the word frequency of the text published on the same day to obtain the tendency features of the content in the past text from the word level; For the cleaned social media text, the pre-designed linguistic statistical word table is used for lexical analysis, specifically: Use LIWC dictionary for lexical analysis, analyze the following seventeen categories of words: positive, negative, anxious, angry, sentimental, social, family, friends, health, space, time, work, leisure, residence, money, region, death, the frequency of occurrence in each text is taken as the tendency and writing style features of the content in the text, and finally it is integrated into the training model; Step 2-2: for the cleaned text, use topic model to count the topic distribution of the text published on the same day to obtain the tendency features of the content in the past text from the topic level; Step 2-3: input the word frequency feature and the topic distribution feature into a back propagation neural network for feature extraction to obtain the reduced text features; Steps 2-4: Categorize users who posted content on the same day according to a series of personal information to obtain the profile characteristics of people who participated in discussions on a certain topic on social media in the past; Step 3 specifically includes: Step 3-1: Merge all the time series vector features obtained in Step 2 and then input them into a time-sensing long short-term memory network; Step 3-2: Use the last hidden layer of the Long Short-Term Memory Network for perceiving time as the input to the final backpropagation neural network to obtain the social media sentiment index for the next day. During model training, the mean squared variance is used as the loss function, and the specific formula is as follows: ; where s is the time step of input features, x = (x1, x2, … x n ), x ∈ R n represents the input feature of the final back propagation neural network, that is, the last hidden layer of the perception time long short-term memory network; y = (y1, y2, … y n ), y ∈ (0, 1), represents the actual daily mood index of the day; f(x, θ) is a model function, which represents the predicted daily mood index output when given x; θ is a model parameter.