# Research on Sentiment Analysis of Online Public Opinion Based on RoBERTa-BiLSTM-Attention Model
## 4 Empirical Analysis
### Model Evaluation  
This part demonstrates the model performance of the BERT-BiLSTM-Attention model on the sentiment corpus of the public opinion event, and the specific results are shown below. Since this study was a three-category study and the ratio of the three categories was not balanced, the metrics were weighted according to the ratio of the three categories to evaluate the overall performance of the RoBERTa-BiLSTM-Attention model, including accuracy, precision, recall, and F1-Score. This study also counted the categorical performance of each category as a way to understand the possible limitations of the results as well as directions for future research, and the specific information is shown in Table 5. Overall, the model accuracy was 91.56%, indicating that the model performed well on the overall dataset. The accuracy rate indicated the proportion of samples predicted by the model to be positive classes that were actually positive classes. The overall precision rate of 90.87% indicated that about 90.87% of the samples predicted by the model as positive classes were correct. Recall indicated the proportion of samples that were actually in the positive category that were correctly predicted as positive by the model. The overall recall rate was 91.07%, indicating that the model was able to identify positive class samples better. The F1 score was the reconciled mean of the precision and recall rates combined. The overall F1-score was 91.17%, indicating that the model struck a good balance between precision and recall. Analysing the sentiment categories, the model performed slightly worse on the positive sentiment category, with an F1 score of 86.73%. The model performed better on the negative sentiment category, with an F1 score of 92.53%. The model also performed better on the neutral sentiment category, with an F1 score of 92.37%. This may have been due to the fact that there was an imbalance in the amount of data for positive emotions compared to the other two categories. \begin{table}
\begin{tabular}{l l} \hline \hline
**Parameter** & **Parameter Value** \\ \hline Number of layers & 2 \\ \hline Hidden layer dimensions & 256 \\ \hline Maximum sequence length & 128 \\ \hline Dropout & 0.2 \\ \hline Epochs & 10 \\ \hline Learning rate & \(2\times 10^{-5}\) \\ \hline Activation function & Relu \\ \hline Loss & categorical\_crossentropy \\ \hline Number of attention heads & 8 \\ \hline Batch size & 32 \\ \hline Optimiser & Adam \\ \hline \hline \end{tabular}
\end{table} 
Table 4: BiLSTM–Attention model parameter configuration. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Class** & **Accuracy** & **Precision** & **Recall** & **F1-Score** \\ \hline All & 0.9156 & 0.9087 & 0.9107 & 0.9117 \\ \hline Positive & - & 0.8661 & 0.8785 & 0.8673 \\ \hline Negative & - & 0.9250 & 0.9259 & 0.9253 \\ \hline Neural & - & 0.9263 & 0.9242 & 0.9237 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Model performance. In addition, analysing the variation of accuracy and loss with the number of iterations during training of the RoBERTa-BiLSTM-Attention model, it was found that in the initial stage of model training (0 to 500 iterations), the accuracy of both the training and validation sets increased rapidly and the loss decreased rapidly. In the middle stage (500 to 1500 iterations), the accuracy of the training set continued to increase and the loss continued to decrease, but the rate of increase in accuracy and decrease in loss for the validation set began to slow down, indicating that the model was beginning to adapt to the training data but had limited ability to generalise to the new data (validation set). The accuracy and loss rates for the training and validation sets stabilised after 1500 iterations but were slightly lower on the validation set than on the training set. Despite the fluctuation in accuracy for the training set, the accuracy for the validation set did not drop significantly, indicating that the model did not have a significant overfitting problem.