|
Algorithm 2 Sentiment prediction model training algorithm. |
-
Require:
Dateset ; The expected number of hidden layers N; The number of pre-training iterations is T
-
Ensure:
Optimization results; Sentiment prediction; Weights
-
1:
Collect early-stage user comments on food public sentiment, analyze them, calculate the number of negative and positive sentiments, and use them as the training dataset .
-
2:
Collect user sentiment feedback on current food public sentiment within the initial time period t.
-
3:
Set the weight of odd-numbered terms as , Sparsity parameter p; Initialize the matrix and random bias vector.
-
4:
Greedy layer-wise algorithm training for hidden layers.
-
5:
Train the first layer using Algorithm 1. The input dataset is the training dataset .
-
6:
Starting from the second layer, use the output of the hidden layer as the input for the next layer, obtaining the encoding-decoding matrix and bias vector for the next hidden layer.
-
7:
Utilize backpropagation combined with gradient optimization techniques to perform top-down layered adjustments of parameters across the entire neural network.
-
8:
Based on the data collected from step 2, make predictions to obtain overall positive and negative results.
-
9:
Construct the weight quantifier: is the number of positive comments and is the number of negative comments
If the prediction result is positive:
Public sentiment index , increase recommendation weight
If the prediction result is negative:
Public sentiment index , decrease recommendation weight
If the prediction result is neutral():
Public sentiment index .
|