<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">JCC</journal-id><journal-title-group><journal-title>Journal of Computer and Communications</journal-title></journal-title-group><issn pub-type="epub">2327-5219</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/jcc.2023.113014</article-id><article-id pub-id-type="publisher-id">JCC-124105</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Computer Science&amp;Communications</subject></subj-group></article-categories><title-group><article-title>
 
 
  Research on Prediction of Sentiment Trend of Food Safety Public Opinion
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Chaofan</surname><given-names>Jiang</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Hu</surname><given-names>Wang</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Changbin</surname><given-names>Jiang</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Di</surname><given-names>Li</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>Management School, Wuhan University of Technology, Wuhan, China</addr-line></aff><pub-date pub-type="epub"><day>10</day><month>03</month><year>2023</year></pub-date><volume>11</volume><issue>03</issue><fpage>189</fpage><lpage>201</lpage><history><date date-type="received"><day>6,</day>	<month>March</month>	<year>2023</year></date><date date-type="rev-recd"><day>28,</day>	<month>March</month>	<year>2023</year>	</date><date date-type="accepted"><day>31,</day>	<month>March</month>	<year>2023</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  
    Emotion has a nearly decisive role in behavior, which will directly affect netizens’ views on food safety public opinion events, thereby affecting the development direction of public opinion on the event, and it is of great significance for food safety network public opinion to predict emotional trends to do a good job in food safety network public opinion guidance. In this paper, the dynamic text representation method XLNet is used to generate word vectors with context-dependent dependencies to distribute the text information of food safety network public opinion. Then, the word vector is input into the CNN-BiLSTM network for local semantic feature and context semantic extraction. The attention mechanism is introduced to give different weights according to the importance of features, and the emotional tendency analysis is carried out. Based on sentiment analysis, sentiment value time series data is obtained, and a time series model is constructed to predict sentiment trends. The sentiment analysis model proposed in this paper can well classify the sentiment of food safety network public opinion, and the time series model has a good effect on the prediction of food safety network public opinion sentiment trend. 
  
 
</p></abstract><kwd-group><kwd>Network Public Opinion</kwd><kwd> Sentiment Analysis</kwd><kwd> Time Series Prediction</kwd><kwd> XLNet</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Emotional analysis is the process of analyzing, processing and extracting emotional subjective text using natural language processing and text analysis technology [<xref ref-type="bibr" rid="scirp.124105-ref1">1</xref>]. According to the type of algorithm used, there are three main methods of emotion analysis: emotion dictionary based method, machine learning based method and deep learning based method. The method based on emotion dictionary is mainly based on the construction of emotion dictionary, combining the comprehensive calculation rules of emotion words, degree adverbs, negative words, etc., to achieve the classification of text emotion [<xref ref-type="bibr" rid="scirp.124105-ref2">2</xref>]. Due to the high dependence on the creation of emotion dictionary, but the artificial emotion dictionary has the problem of incomplete emotion words, unable to identify the emotion tendency in different contexts, and unable to add new words in time, the expansion of emotion dictionary needs a lot of manpower and the system mobility is poor, so its robustness is not ideal [<xref ref-type="bibr" rid="scirp.124105-ref3">3</xref>]. The method based on machine learning mainly uses the text analysis technology to extract the relevant language features in the text, and uses the traditional machine learning method to treat the emotion analysis as a classification problem. Wawre [<xref ref-type="bibr" rid="scirp.124105-ref4">4</xref>] and others applied three classifiers to the emotional dichotomy of film reviews, providing ideas for the analysis of public sentiment. Abbasi [<xref ref-type="bibr" rid="scirp.124105-ref5">5</xref>] proposed a rule-based multivariate text feature extraction method, which considers the connection between semantic information and grammatical features, and can effectively remove the noise information and redundant features of the text. Dragoni [<xref ref-type="bibr" rid="scirp.124105-ref6">6</xref>] first extracts emotional words according to the emotional dictionary, and then combines these emotional words with SVM models in machine learning, and performs sentiment classification after extracting text features based on machine learning methods. Machine learning methods to achieve good classification effects require a lot of manual energy consumption, and the applicable domain of text is limited, that is, the feature set in one domain may not be adapted to another domain, and the portability of the model is poor. Based on the deep learning method, a network model is created with the function of automatic extraction of feature text classification, which can solve the shortcomings of the first two methods. Y. Kim [<xref ref-type="bibr" rid="scirp.124105-ref7">7</xref>] proposed to use CNN for text emotion analysis for the first time and obtained good results. Bahdanau [<xref ref-type="bibr" rid="scirp.124105-ref8">8</xref>] introduced the attention mechanism into the text translation task, and improved the effect of the text translation task by giving different weights to different features of the Chinese word vector of the text translation task. Deep learning has achieved remarkable results in various NLP tasks [<xref ref-type="bibr" rid="scirp.124105-ref9">9</xref>]. This method has become a very popular method in recent years because of its high performance. As many deep learning methods in natural language processing use word embedding learning algorithm to represent the vector of each word or sentence [<xref ref-type="bibr" rid="scirp.124105-ref10">10</xref>], word embedding method refers to the word vector obtained by using unsupervised learning expectation to convert text information into serialized vector, and then apply it to downstream problems. Google’s brain introduces the XLNet model, which uses the autoregressive language model and the replacement language model to solve the defects of the AR model. The AR model is a two-way model that cannot capture context information, and has achieved the best results of 18 NLP tasks [<xref ref-type="bibr" rid="scirp.124105-ref11">11</xref>]. Alshahrani [<xref ref-type="bibr" rid="scirp.124105-ref12">12</xref>] identified the optimism and pessimism in Twitter messages through finetune emotion analysis XLNet model, and achieved significant results. Sweidan [<xref ref-type="bibr" rid="scirp.124105-ref13">13</xref>] used XLNet in combination with the BiLSTM network for the aspect emotion classification in online user reviews, improving the overall accuracy of emotion classification. Use XLNet dynamic text representation instead of traditional static text representation to perform the initialization of downstream tasks. It can study extensive and in-depth text information at the same time. It can improve the accuracy of emotional analysis.</p><p>The emotional trend prediction studied in this paper mainly refers to the prediction and analysis of the changes in emotional attitudes contained in public comments with the development of a hot topic of a food safety event. Traditional time series prediction methods are mainly based on autoregressive (AR), autoregressive moving average (ARMA) and differential moving average autoregressive model [<xref ref-type="bibr" rid="scirp.124105-ref14">14</xref>] [<xref ref-type="bibr" rid="scirp.124105-ref15">15</xref>] [<xref ref-type="bibr" rid="scirp.124105-ref16">16</xref>]. In terms of the control of online public opinion, Ren Juwei [<xref ref-type="bibr" rid="scirp.124105-ref17">17</xref>] used the emotional time series analysis method to predict the social emotional trend of microblog events and analyze the emotional change trend of users on microblog topics in different time periods. Sun Jiaqi [<xref ref-type="bibr" rid="scirp.124105-ref18">18</xref>] used the Shanghai Stock Exchange Index Bar of Oriental Fortune as the data source to build investor comment data sets, build sentiment analysis models, propose time series prediction models, predict investor sentiment trends, and provide reference for investment decisions by judging the changes of investor sentiment trends.</p></sec><sec id="s2"><title>2. Sentiment Analysis Model Based on XLNet and CNN-BiLSTM</title><sec id="s2_1"><title>2.1. Overall Structure of Algorithm</title><p>The XLNet-CNN-BiLSTM-Att model consists of four main components, namely the XLNet layer, CNN layer, BiLSTM layer, and Attention layer. The model architecture is shown in <xref ref-type="fig" rid="fig1">Figure 1</xref>. The overall process of the model is as follows. First, the XLNet layer is used to obtain word vectors containing contextual semantic information. Second, then local semantic features are extracted using CNN. Then, BiLSTM extracts contextually relevant features. Finally, the attention mechanism is introduced to assign weights to the extracted features to highlight the key information. The model utilizes a softmax classifier for sentiment classification.</p><p>XLNet layer: The XLNet layer is used to vectorize text. The text sequence X ( X 1 , X 2 , … , X n ) with input length n is preprocessed, and the word vector corresponding to each word g ( g 1 ( 2 ) , g 2 ( 2 ) , … , g n ( 2 ) ) is learned through the XLNet model. In which the word vector g encodes its context information and its own position information. The word vectors learned by the XLNet layer will be used as input data for the CNN layer.</p><p>CNN layer: The purpose of the CNN layer is to learn the local features of a text. It inputs the word vector calculated by the XLNet layer into the convolution layer and completes the feature extraction of the input text through three filters. The local feature matrix C<sub>j</sub> obtained after the convolution layer is input into the pooling layer, and down-sampling is performed by the MaxPooling technique to obtain the optimal solution of the local value.</p><p>BiLSTM layer: The BiLSTM layer aims to learn the contextual information features of words in sequence data. The feature vector calculated by the CNN layer is input into the hidden layer of BiLSTM. A standard LSTM computes a sequence of hidden layer vectors from one direction, while a bidirectional LSTM computes from two different directions and finally combines the results from both directions for output. The forward hidden layer vector is h → , the backward hidden layer vector is h ← , and the output vector of the hidden layer at the moment is v i = h ← +   h → .</p><p>Attention layer: The Attention layer is to assign different weights to the feature vectors. The Attention mechanism assigns different weights to the feature vectors selected by the BiLSTM layer according to different degrees of influence a (a<sub>1</sub>, a<sub>2</sub>, …, a<sub>3</sub>), so as to improve the attention of the model to important features. Finally, the text sentiment is calculated by the softmax activation function.</p></sec><sec id="s2_2"><title>2.2. Experimental Design and Result Analysis</title><sec id="s2_2_1"><title>2.2.1. Datasets</title><p>In June 2020, four departments, including the State Administration for Market Regulation and the Ministry of Education of the People’s Republic of China, jointly issued the “Campus Food Safety Protection Action Plan (2020-2022)”, which clearly proposes to strictly prevent and control campus food safety risks and prevent the occurrence of major food safety accidents. Based on the background, this paper uses Python and XPath technology to customize a web crawler to crawl a totally of 86,670 related blog posts from several food safety events, including “Mouldy and rotten meat found in a primary school canteen of Chengdu”, “Dead rats found in school meals in Xinzhou”, “Food poisoned in the school canteen in Bazhou”, and “Handan school students have diarrhea”. After preprocessing such as deleting duplicates and objective invalid remarks, 41,420 annotated Weibo data with balanced positive and negative sentiments are finally obtained as training data. At the same time, we crawled three other events, including “Mass vomiting of students in Henan”, “The kitchen of one Tianjin school is untidy”, and “Students vomited after dinner in Anhui”, that broke out on Weibo and had a wide range of effects, as test data. To ensure the validity of the data, the text content was first classified by the Baidu Sentiment Analysis API. Second, we manually annotated the text content and classified it as positive or negative. Finally, a more accurate positive and negative corpus is obtained by comparing and correcting the annotations obtained by the manual and the Baidu API. <xref ref-type="table" rid="table1">Table 1</xref> shows the descriptive statistic of test datasets.</p></sec><sec id="s2_2_2"><title>2.2.2. Experimental Setup</title><p>This study uses the jieba package in python to segment the training data and download the base version of the Chinese XLNet pre-training model released by the Harbin Institute of Technology Xunfei Joint Laboratory. The XLNet model that had been pre-trained on the general-purpose dataset was further pre-trained on our training dataset. The parameters of the XLNet model were fine-tuned using CNN, BiLSTM, and attention mechanisms, which is equivalent to transferring the model from the general-purpose domain to food safety sentiment analysis. After obtaining the word vectors generated by XLNet pre-training model, the microblog sentiment analysis model is trained in the environment with the deep learning framework Tensorflow 2.0.0. A grid search method is used to adjust the main parameters and obtain the ideal set of parameters. The values of the model parameters are shown in <xref ref-type="table" rid="table2">Table 2</xref>.</p></sec></sec><sec id="s2_3"><title>2.3. Experimental Evaluation Indicators</title><p>The common metrics used to evaluate the performance of sentiment analysis models are Precision (P), Recall (R), F1-score (F<sub>1</sub>), Accuracy (Acc) and Loss rate (L).</p><p>A c c = T P + T N T P + T N + F P + F N &#215; 100 % P = T P T P + F P &#215; 100 % (1)</p><p>R = T P T P + F N &#215; 100 % F 1 = 2 &#215; P &#215; R P &#215; R &#215; 100 % L = − [ log y ^ + ( 1 − y ) log ( 1 − y ^ ) ] (2)</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> Test event data</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Event name</th><th align="center" valign="middle" >Name abbreviation</th><th align="center" valign="middle" >Positive</th><th align="center" valign="middle" >Negative</th><th align="center" valign="middle" >Total</th></tr></thead><tr><td align="center" valign="middle" >Mass vomiting of students in Henan</td><td align="center" valign="middle" >Henan event</td><td align="center" valign="middle" >2152</td><td align="center" valign="middle" >2203</td><td align="center" valign="middle" >4355</td></tr><tr><td align="center" valign="middle" >The kitchen of one Tianjin school is untidy</td><td align="center" valign="middle" >Tianjin event</td><td align="center" valign="middle" >1999</td><td align="center" valign="middle" >2029</td><td align="center" valign="middle" >4028</td></tr><tr><td align="center" valign="middle" >Students vomited after dinner in Anhui</td><td align="center" valign="middle" >Anhui event</td><td align="center" valign="middle" >1929</td><td align="center" valign="middle" >2124</td><td align="center" valign="middle" >4053</td></tr></tbody></table></table-wrap><table-wrap id="table2" ><label><xref ref-type="table" rid="table2">Table 2</xref></label><caption><title> Model parameters</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Parameter name</th><th align="center" valign="middle" >Parameter value</th></tr></thead><tr><td align="center" valign="middle" >Eembedding size</td><td align="center" valign="middle" >768</td></tr><tr><td align="center" valign="middle" >Convolution kernels num</td><td align="center" valign="middle" >128, 128, 128</td></tr><tr><td align="center" valign="middle" >convolution kernels length</td><td align="center" valign="middle" >3, 4, 5</td></tr><tr><td align="center" valign="middle" >Batch size</td><td align="center" valign="middle" >32</td></tr><tr><td align="center" valign="middle" >Optimizer</td><td align="center" valign="middle" >Adam</td></tr><tr><td align="center" valign="middle" >Sentence length</td><td align="center" valign="middle" >70</td></tr><tr><td align="center" valign="middle" >Learning rate</td><td align="center" valign="middle" >0.00005</td></tr><tr><td align="center" valign="middle" >Lstm units</td><td align="center" valign="middle" >128</td></tr><tr><td align="center" valign="middle" >Dropout rate</td><td align="center" valign="middle" >0.5</td></tr><tr><td align="center" valign="middle" >Validation split</td><td align="center" valign="middle" >0.3</td></tr></tbody></table></table-wrap></sec><sec id="s2_4"><title>2.4. Experimental Results</title><p>In this experiment, three models were chosen as experimental control models: Word2Vec-BiLSTM, XLNet and XLNet-CNN. The sentiment analysis experiments were conducted on three test events, including Henan event, Tianjin event, and Anhui event. <xref ref-type="fig" rid="fig2">Figure 2</xref> depicts the dynamic changes in the accuracy and loss rate of the model training over the 10 epochs. According to the accuracy and loss rates of the validation set data during the training phase, we may conclude that the model proposed in this paper outperforms the other five models.</p><p>In this study, the optimal parameter values of XLNet-CNN-BiLSTM were utilized to classify Internet users’ sentiments, and the results are presented in <xref ref-type="table" rid="table3">Table 3</xref>. The average accuracy of the three test events is 94.12%, with the Anhui event having the highest accuracy at 94.75%. This demonstrates that the XLNet-CNN-BiLSTM model proposed in this research is capable of achieving outstanding performance in Internet public opinion sentiment analysis. Besides, the model outperformed the other five models in terms of accuracy in all three events tested. This implies that the dynamic text representation approach is superior to the static text representation method Word2Vec for classification tasks.</p></sec></sec><sec id="s3"><title>3. Prediction of Public Sentiment Trend of Food Safety Network Based on LSTM Network</title><sec id="s3_1"><title>3.1. Construction of Emotional Value Sequence of Food Safety Network Public Opinion</title><p>In this paper, the emotional value of online public opinion text on food safety is constructed in the same way as the bullish index used by Antweiler in the stock market, which is used to reflect the emotional trend of netizens in public opinion events over a period of time, and can integrate emotional information. The calculation method of the bullish index combines the bullish and bearish sentiment of the investors in the stock market. It is a classic calculation method in the</p><table-wrap id="table3" ><label><xref ref-type="table" rid="table3">Table 3</xref></label><caption><title> Models test result</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Model</th><th align="center" valign="middle" >Evaluation indicators</th><th align="center" valign="middle" >Henan event</th><th align="center" valign="middle" >Tianjin event</th><th align="center" valign="middle" >Anhui event</th></tr></thead><tr><td align="center" valign="middle"  rowspan="4"  >XLNet-CNN-BiLSTM</td><td align="center" valign="middle" >Acc</td><td align="center" valign="middle" >93.87</td><td align="center" valign="middle" >93.76</td><td align="center" valign="middle" >94.75</td></tr><tr><td align="center" valign="middle" >P</td><td align="center" valign="middle" >95.09</td><td align="center" valign="middle" >93.98</td><td align="center" valign="middle" >95.15</td></tr><tr><td align="center" valign="middle" >R</td><td align="center" valign="middle" >94.86</td><td align="center" valign="middle" >94.32</td><td align="center" valign="middle" >94.76</td></tr><tr><td align="center" valign="middle" >F1</td><td align="center" valign="middle" >94.97</td><td align="center" valign="middle" >94.15</td><td align="center" valign="middle" >94.73</td></tr><tr><td align="center" valign="middle"  rowspan="4"  >XLNet-CNN</td><td align="center" valign="middle" >Acc</td><td align="center" valign="middle" >91.96</td><td align="center" valign="middle" >92.04</td><td align="center" valign="middle" >92.12</td></tr><tr><td align="center" valign="middle" >P</td><td align="center" valign="middle" >92.41</td><td align="center" valign="middle" >92.33</td><td align="center" valign="middle" >92.21</td></tr><tr><td align="center" valign="middle" >R</td><td align="center" valign="middle" >92.91</td><td align="center" valign="middle" >91.97</td><td align="center" valign="middle" >93.83</td></tr><tr><td align="center" valign="middle" >F1</td><td align="center" valign="middle" >92.66</td><td align="center" valign="middle" >92.15</td><td align="center" valign="middle" >93.17</td></tr><tr><td align="center" valign="middle"  rowspan="4"  >XLNet</td><td align="center" valign="middle" >Acc</td><td align="center" valign="middle" >90.97</td><td align="center" valign="middle" >90.63</td><td align="center" valign="middle" >91.13</td></tr><tr><td align="center" valign="middle" >P</td><td align="center" valign="middle" >91.13</td><td align="center" valign="middle" >91.38</td><td align="center" valign="middle" >91.83</td></tr><tr><td align="center" valign="middle" >R</td><td align="center" valign="middle" >90.79</td><td align="center" valign="middle" >90.79</td><td align="center" valign="middle" >90.41</td></tr><tr><td align="center" valign="middle" >F1</td><td align="center" valign="middle" >90.96</td><td align="center" valign="middle" >91.08</td><td align="center" valign="middle" >91.11</td></tr><tr><td align="center" valign="middle"  rowspan="4"  >Word2Vec-BiLSTM</td><td align="center" valign="middle" >Acc</td><td align="center" valign="middle" >82.46</td><td align="center" valign="middle" >81.96</td><td align="center" valign="middle" >82.1</td></tr><tr><td align="center" valign="middle" >P</td><td align="center" valign="middle" >82.39</td><td align="center" valign="middle" >82.18</td><td align="center" valign="middle" >84.23</td></tr><tr><td align="center" valign="middle" >R</td><td align="center" valign="middle" >83.66</td><td align="center" valign="middle" >81.93</td><td align="center" valign="middle" >83.14</td></tr><tr><td align="center" valign="middle" >F1</td><td align="center" valign="middle" >83.02</td><td align="center" valign="middle" >82.05</td><td align="center" valign="middle" >83.68</td></tr></tbody></table></table-wrap><p>measurement of investor sentiment in the stock market. It is similar to the positive and negative emotional tendencies of the Internet users of the food safety network public opinion on public opinion events. Therefore, this method is used for reference to construct the emotional value of the food safety network public opinion in this paper. Referring to the bullish index formula, the emotional value calculation formula is S t = ln [ ( 1 + n t p o s ) / ( 1 + n t n e g ) ] , n t p o s indicates the number of blog posts with positive emotions in the food safety network public opinion event in a certain period, n t n e g indicates the number of posts with negative emotions in a certain period.</p><p>In order to use the time series model to predict the emotional trend more accurately, the emotional value calculated for each blog article is stored in chronological order. The emotional value data of “Henan Event”, “Anhui Event” and “Tianjin Event” are selected as the data source of the emotional trend prediction model, Take the average of the emotional values of the online public opinion blog posts corresponding to these food safety events every 30 minutes and give the emotional value sequence { S 1 , S 2 , … , S t } that constitutes the corresponding time point. The emotional value time series is divided into training sets and test sets. A set of training samples is used to train LSTM to generate memory, and then the prediction set is input into the training LSTM to obtain the output of the prediction set.</p></sec><sec id="s3_2"><title>3.2. Wavelet Analysis</title><p>Because the emotional tendency of blog posts is easily affected by many factors such as opinion leaders, Internet users’ relevance and the nature of events, it usually contains a lot of noise, so the constructed temporal emotional value also contains noise. The wavelet analysis can refine the signal analysis in many degrees through the operation functions such as expansion and translation. It can eliminate the noise in the time series data, but also cannot change the characteristics of the original time series data. Therefore, this paper uses wavelet denoising to eliminate the noise components in the time series data of the emotional value of the public opinion of the food safety network, reduce the interference impact of noise on the LSTM model, and improve the prediction function of the model. Wavelet analysis can decompose each layer of input data into a low frequency signal and a high frequency signal, and can further decompose the low frequency signal into a low frequency signal and a high frequency signal, and so on.</p></sec><sec id="s3_3"><title>3.3. LSTM Time Series Prediction Method</title><p>The LSTM model can mine the information in the long time series data. Compared with the problem of gradient disappearance or explosion that may occur in RNN, LSTM has effectively solved the problem of long-term dependence and gradient disappearance by deliberately improving the internal structure of RNN and adding three gating units, namely input gate, forgetting gate and output gate. The purpose of this paper is to predict the emotional trend of food safety network public opinion through a neural network model. Considering the impact of historical emotional value time series data on the emotional trend, LSTM can effectively use historical information and has advantages in processing long-term dependent data, and build an emotional value time series prediction model based on LSTM model.</p></sec><sec id="s3_4"><title>3.4. Experimental Design and Result Analysis</title><sec id="s3_4_1"><title>3.4.1. Experiment Description and Parameter Setting</title><p>1) Wavelet analysis</p><p>The db3 wavelet base is used to decompose the time series data of the public opinion sentiment value of the food safety network by three layers of wavelet, and reconstruct that the public opinion sentiment value of the food safety network is the time series data, so as to improve the extrapolation ability of the subsequent LSTM model. The emotional value time series data of the three original food safety network public opinion events and the reconstructed emotional value time series data are shown in Figures 3-5. From the original emotional value time series data chart of the three events and the reconstructed emotional value time series data chart, it can be seen that the emotional value time series data of the food safety network public opinion after the db3 wavelet decomposition and reconstruction can effectively raise the original data noise and retain its approximate signal to the maximum extent, Therefore, it is theoretically scientific to establish LSTM prediction model based on the reconstructed emotional value time series data.</p><p>2) Parameter description</p><p>Tensorflow is currently the most popular open source machine learning framework based on Python development language. This paper uses the grid search method to find the main parameters of the LSTM model, and obtains the optimal parameter set of the model as shown in <xref ref-type="table" rid="table4">Table 4</xref>.</p><table-wrap id="table4" ><label><xref ref-type="table" rid="table4">Table 4</xref></label><caption><title> Parameters table</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Parameter</th><th align="center" valign="middle" >Value</th></tr></thead><tr><td align="center" valign="middle" >Units</td><td align="center" valign="middle" >64</td></tr><tr><td align="center" valign="middle" >Activation</td><td align="center" valign="middle" >Relu</td></tr><tr><td align="center" valign="middle" >Optimizer</td><td align="center" valign="middle" >Adam</td></tr><tr><td align="center" valign="middle" >LSTM units</td><td align="center" valign="middle" >128</td></tr><tr><td align="center" valign="middle" >Dropout rate</td><td align="center" valign="middle" >0.3</td></tr></tbody></table></table-wrap></sec><sec id="s3_4_2"><title>3.4.2. Experimental Evaluation Indicators</title><p>This paper adopts the Evaluation indicators commonly used in the prediction model as the way to measure the error between the predicted value and the real value, including the average absolute percentage error (MAPE), the average absolute error (MAE), and the root mean square error (RMSE).</p></sec><sec id="s3_4_3"><title>3.4.3. Experimental Results and Discussion</title><p>When designing the comparative experiment, the previous experience was used for reference. This experiment uses time series data to train the trend model of public sentiment. Therefore, this paper designs three experimental schemes based on LSTM neural network model for prediction and comparison: 1) LSTM Shenjing network model; 2) BP neural network model; 3) The random forest (RF) model draws the comparison chart of the actual value and predicted value of the above three experimental schemes for three public opinion events, as shown in <xref ref-type="fig" rid="fig6">Figure 6</xref>.</p><p>The ordinate in the figure above represents the processed emotional value, the abscissa represents the amount of data, the purple line is the actual value, and the other lines are the predicted values of each model. From the figure, we can clearly see the fitting degree of the actual value and the predicted value of the three schemes. The prediction effect of RF model is general, and there are many places with large errors; The fitting effect of BP model is good, but it is not accurate enough; The LSTM model can reach a relatively accurate degree, and it can be seen from the image that only local small errors exist. In this paper, MAPE, MAE and RMSE are selected as the evaluation criteria for the model performance. The model performance evaluation of the three experimental schemes designed is listed in <xref ref-type="table" rid="table5">Table 5</xref>.</p><table-wrap id="table5" ><label><xref ref-type="table" rid="table5">Table 5</xref></label><caption><title> Model performance evaluation table</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Model</th><th align="center" valign="middle" >Evaluation indicators</th><th align="center" valign="middle" >Henan incident</th><th align="center" valign="middle" >Tianjin incident</th><th align="center" valign="middle" >Anhui incident</th></tr></thead><tr><td align="center" valign="middle"  rowspan="3"  >LSTM</td><td align="center" valign="middle" >MAPE</td><td align="center" valign="middle" >1.534</td><td align="center" valign="middle" >1.365</td><td align="center" valign="middle" >1.962</td></tr><tr><td align="center" valign="middle" >MAE</td><td align="center" valign="middle" >0.0213</td><td align="center" valign="middle" >0.0246</td><td align="center" valign="middle" >0.0452</td></tr><tr><td align="center" valign="middle" >RMSE</td><td align="center" valign="middle" >0.0271</td><td align="center" valign="middle" >0.0299</td><td align="center" valign="middle" >0.0527</td></tr><tr><td align="center" valign="middle"  rowspan="3"  >BP</td><td align="center" valign="middle" >MAPE</td><td align="center" valign="middle" >3.701</td><td align="center" valign="middle" >4.536</td><td align="center" valign="middle" >3.227</td></tr><tr><td align="center" valign="middle" >MAE</td><td align="center" valign="middle" >0.0516</td><td align="center" valign="middle" >0.0825</td><td align="center" valign="middle" >0.0712</td></tr><tr><td align="center" valign="middle" >RMSE</td><td align="center" valign="middle" >0.0676</td><td align="center" valign="middle" >0.0983</td><td align="center" valign="middle" >0.0795</td></tr><tr><td align="center" valign="middle"  rowspan="3"  >RF</td><td align="center" valign="middle" >MAPE</td><td align="center" valign="middle" >4.5678</td><td align="center" valign="middle" >4.2698</td><td align="center" valign="middle" >2.7906</td></tr><tr><td align="center" valign="middle" >MAE</td><td align="center" valign="middle" >0.0624</td><td align="center" valign="middle" >0.0757</td><td align="center" valign="middle" >0.0631</td></tr><tr><td align="center" valign="middle" >RMSE</td><td align="center" valign="middle" >0.0669</td><td align="center" valign="middle" >0.0977</td><td align="center" valign="middle" >0.0808</td></tr></tbody></table></table-wrap><p>According to the comparison results in <xref ref-type="table" rid="table5">Table 5</xref>, the values of the three evaluation criteria of LSTM model are significantly different from those of BPNN model and RF model. This shows that the prediction effect of emotional value time series data in LSTM prediction model is better than that of BPNN and RF models.</p></sec></sec></sec><sec id="s4"><title>4. Conclusion</title><p>Aiming at the problem of traditional word vector model, a classification algorithm of public sentiment on food safety network based on XLNet model is proposed. Taking full advantage of the advantage that XLNet model can represent Chinese text at the character level and the accuracy is not affected by the word segmentation effect, XLNet model is used to convert the word vector of text information. The structure of CNN-BLSTM emotion classification algorithm based on XLNet model proposed in this paper is shown in detail, including the introduction of each layer of the network and the training of the model. By setting up contrast experiments, the effectiveness of the proposed method is proved, and a relatively ideal effect of emotion classification is obtained. Based on the results of emotion classification, the emotional value of fixed time unit is calculated and the emotional value time series is constructed. Based on the advantages of LSTM model in time series data, LSTM model is proposed to predict emotional trend, and good prediction results are achieved.</p></sec><sec id="s5"><title>Conflicts of Interest</title><p>The authors declare no conflicts of interest regarding the publication of this paper.</p></sec><sec id="s6"><title>Cite this paper</title><p>Jiang, C.F., Wang, H., Jiang, C.B. and Li, D. (2023) Research on Prediction of Sentiment Trend of Food Safety Public Opinion. Journal of Computer and Communications, 11, 189-201. https://doi.org/10.4236/jcc.2023.113014</p></sec></body><back><ref-list><title>References</title><ref id="scirp.124105-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Pang, B. and Lee, L. (2008) Opinion Mining and Sentiment Analysis. Foundations and Trends? in Information Retrieval, 2, 1-135. https://doi.org/10.1561/1500000011 </mixed-citation></ref><ref id="scirp.124105-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Xu, L.H. and Lin, H.F. (2008) Constructing the Affective Lexicon Ontol-ogy. Journal of the China Society for Scientific and Technical Information, 27, 180-185.</mixed-citation></ref><ref id="scirp.124105-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Shi, W. and Wang, H.W. (2013) Sentiment Analysis of Chinese Online Reviews Based on Semantics. Journal of the China Society for Scientific and Technical Information, 32, 860-867.</mixed-citation></ref><ref id="scirp.124105-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Wawre, S.V. and Deshmukh, S.N. (2016) Sentiment Classification Using Machine Learning Techniques. International Journal of Science and Research (IJSR), 5, 819-821.  
https://doi.org/10.21275/v5i4.NOV162724</mixed-citation></ref><ref id="scirp.124105-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Abbasi, A., France, S., Zhang, Z., et al. (2010) Selecting Attributes for Sentiment Classification Using Feature Relation Networks. IEEE Transactions on Knowledge and Data Engineering, 23, 447-462. https://doi.org/10.1109/TKDE.2010.110</mixed-citation></ref><ref id="scirp.124105-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Dragoni, M. and Petrucci, G. (2018) A Fuzzy-Based Strategy for Multi-Domain Sentiment Analysis. International Journal of Approximate Reasoning, 93, 59-73.  
https://doi.org/10.1016/j.ijar.2017.10.021</mixed-citation></ref><ref id="scirp.124105-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Kim, Y. (2014) Convolutional Neural Networks for Sentence Classification. 1746-1751.  
https://doi.org/10.3115/v1/D14-1181</mixed-citation></ref><ref id="scirp.124105-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Bahdanau, D., Cho, K. and Bengio, Y. (2014) Neural Machine Translation by Jointly Learning to Align and Translate. arXiv preprint arXiv:1409.0473.</mixed-citation></ref><ref id="scirp.124105-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Cliche, M. (2017) BB_twtr at SemEval-2017 Task 4: Twitter Sentiment Analysis with CNNs and LSTMs. arXiv preprint arXiv:1704.06125.  
https://doi.org/10.18653/v1/S17-2094</mixed-citation></ref><ref id="scirp.124105-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">Yadav, A. and Vishwakarma, D.K. (2020) Sentiment Analysis Using Deep Learning Architectures: A Review. Artificial Intelligence Review, 53, 4335-4385.  
https://doi.org/10.1007/s10462-019-09794-5</mixed-citation></ref><ref id="scirp.124105-ref11"><label>11</label><mixed-citation publication-type="other" xlink:type="simple">Yang, Z., Dai, Z., Yang, Y., et al. (2019) Xlnet: Generalized Autoregressive Pretraining for Language Understanding. Advances in Neural Information Processing Systems, 32.</mixed-citation></ref><ref id="scirp.124105-ref12"><label>12</label><mixed-citation publication-type="other" xlink:type="simple">Alshahrani, A., Ghaffari, M., Amir, K., et al. (2020) Identifying Optimism and Pessimism in Twitter Messages Using Xlnet and Deep Consensus. 2020 International Joint Conference on Neural Networks (IJCNN), 1-8.  
https://doi.org/10.1109/IJCNN48605.2020.9206948</mixed-citation></ref><ref id="scirp.124105-ref13"><label>13</label><mixed-citation publication-type="other" xlink:type="simple">Sweidan, A.H., El-Bendary, N. and Al-Feel, H. (2021) Sentence-Level Aspect-Based Sentiment Analysis for Classifying Adverse Drug Reactions (ADRs) Using Hybrid Ontology-XLNet Transfer Learning. IEEE Access, 9, 90828-90846.  
https://doi.org/10.1109/ACCESS.2021.3091394</mixed-citation></ref><ref id="scirp.124105-ref14"><label>14</label><mixed-citation publication-type="other" xlink:type="simple">Chisci, L., Mavino, A., Perferi, G., et al. (2010) Real-Time Epileptic Seizure Prediction Using AR Models and Support Vector Machines. IEEE Transactions on Biomedical Engineering, 57, 1124-1132. https://doi.org/10.1109/TBME.2009.2038990</mixed-citation></ref><ref id="scirp.124105-ref15"><label>15</label><mixed-citation publication-type="other" xlink:type="simple">Faruk, D.?. (2010) A Hybrid Neural Network and ARIMA Model for Water Quality Time Series Prediction. Engineering Applications of Artificial Intelligence, 23, 586-594. https://doi.org/10.1016/j.engappai.2009.09.015 </mixed-citation></ref><ref id="scirp.124105-ref16"><label>16</label><mixed-citation publication-type="other" xlink:type="simple">Rojas, I., Valenzuela, O., Rojas, F., et al. (2008) Soft-Computing Techniques and ARMA Model for Time Series Prediction. Neurocomputing, 71, 519-537.  
https://doi.org/10.1016/j.neucom.2007.07.018</mixed-citation></ref><ref id="scirp.124105-ref17"><label>17</label><mixed-citation publication-type="other" xlink:type="simple">Ren, J.W., Yang, L., Wu, X.F., et al. (2017) Public Sentiment Trend Prediction of Microblog Events Based on Affective Commonsense Knowledge. Journal of Chinese Information Processing, 31, 169-178.</mixed-citation></ref><ref id="scirp.124105-ref18"><label>18</label><mixed-citation publication-type="other" xlink:type="simple">Sun, J.Q., Wang, X., Yang, P., et al. (2021) Predicting Sentiment Trend by Time Series Model and Sentiment Analysis. Computer Engineering and Design, 42, 2938-2945.</mixed-citation></ref></ref-list></back></article>