# Sentiment Analysis of Comment Texts on Online Courses Based on Hierarchical Attention Mechanism
## 4 Experimental Process
### Experimental Results and Analysis  
The results of the comparison between the seven baselines and the HAG are shown in the following Table 3.  
It can be seen from Table 2 that the experimental results of all models on the MOOC and MOOC and Ke data sets are quite different for four reasons: First, the data of MOOC is relatively large compared with the data of MOOC and Ke, and the number of data in MOOC is 11,036, while the number of data in MOOC and Ke is 1810. Secondly, the MOOC and Ke data set is divided into positive and negative categories, while the reviews in MOOC and Ke are divided into positive, neutral, and negative categories, which increases the difficulty of classification to a certain extent. Then, the proportion of positive  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Dataset** & **Positive** & **Neutral** & **Negative** \\ \hline MOOC-Train & 4609 & 0 & 4068 \\ MOOC-Val & 598 & 0 & 531 \\ MOOC-Test & 600 & 0 & 630 \\ MOOC and Ke-Train & 639 & 609 & 200 \\ MOOC and Ke-Test & 180 & 141 & 41 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Data set distribution.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Methods** & **MOOC (acc and F1)** & **MOOC and Ke (acc)** & **R8** \\ \hline CNN & 0.903 and 0.911 & 0.453 & 95.34 \\ LSTM & 0.912 and 0.918 & 0.461 & 96.09 \\ LSTM-Attention & 0.932 and 0.920 & 0.472 & 96.59 \\ BERT & 0.932 and 0.940 & 0.495 & 98.03 \\ RoBERTa & 0.934 and 0.945 & 0.496 & 98.23 \\ ERNIE & 0.937 and 0.936 & 0.496 & 98.04 \\ HAN & 0.940 and 0.938 & 0.499 & 97.65 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparative experimental results.  
and negative MOOCs relative to the MOOC and Ke dataset is more balanced. Finally, the review data in MOOC is clean, while the MOOC and Ke data set is noisy, which limits the accuracy of sentiment classification of MOOC and Ke data to some extent. In these three data sets, the accuracy of CNN is lower than in other models. CNN plays a significant role in extracting local features and can obtain sentiment word information to a certain extent. LSTM can learn long-term dependencies and extract the sequence information of text effectively. Compared with CNN, the accuracy of LSTM on MOOC. MOOC, Ke, and R8 are increased by 0.9%, 0.8%, and 0.75%, respectively, and the accuracy of F1 is increased by 0.07%. The accuracy of the model is improved by the attention mechanism. BERT is also a classic model in sentiment analysis. BERT uses a multi-head attention mechanism to give the output of the attention layer, which contains the coding representation information in different subspaces, thus enhancing the expressive power of the model. Since the use of BERT for emotion analysis, various improvement methods based on BERT have been proposed. RoBERTa uses a dynamic masking mechanism and abandons that NSP (Next Sentence Predict) task; compared with BERT, RoBERTa performs slightly better on both datasets. Ernie also adjusts the mask mechanism in BERT. In the sentiment analysis of Chinese online courses, Ernie can identify the importance of words better than BERT. HAN is inferior to BERT-based models (i.e., BERT, Roberta, and Ernie) on long news texts of R8. This is partly due to the randomly initialized representation of HAN. Moreover, for the long news texts, BERT could alleviate the problem of vanishing gradients. However, in the class comments, HAN has achieved the best experimental results. HAN first uses CNN to extract local sentiment information and then uses the gate mechanism to filter the local sentiment information through the overall text information obtained by LSTM. At the same time, it uses the local sentiment information extracted by CNN to enrich the sequence information extracted by LSTM. Then through the weighting of the hierarchical attention mechanism, the sentiment tendency experiment of online classroom network reviews is obtained, and the experimental results once again prove the effectiveness of the HAN proposed in this study.