# Weighted Matrix Factorization Recommendation Model Incorporating Social Trust
## 4 Trust-Based Weighted Matrix Factorization
### Trust-WMF Recommendation Model  
This paper designs a new type of trust network-based weighted matrix factorization recommendation model (Trust-WMF), whose architecture, as shown in Figure 2, is divided into four parts:  
1. Utilizing Equation (3), predicted ratings based on the user's social network are calculated. 2. Based on user historical ratings, the predicted ratings are calculated using Equations (1) and (2), and this part includes two filtering layers. The role of Filter Layer 1 is to screen out users with fewer commonly rated items before calculating the similarity between users, ensuring the reliability of the calculated user similarity. Filter Layer 2 aims to filter out pairs of users with low similarity before predicting ratings based on user similarity, further reducing the impact of noise data on predicted ratings. 3. Predicted ratings based on trust relationships and similarity relationships calculated in the first two parts are nonlinearly combined using Equation (4). 4. After combining the three parts of predicted ratings, they are integrated with user historical ratings, and the improved weighted matrix factorization model within the Trust-WMF recommendation model is used to further capture the latent features and relationships of users and items. As shown in the diagram, the Trust-WMF model generates three parts of predicted ratings after the calculations in the first three steps. These predicted ratings need to be combined with user historical ratings to form four parts of data to be processed. Subsequently, these combined data undergo matrix factorization to yield the final predicted ratings. Since the four parts of ratings differ in credibility and the impact of noise data they contain on the results also varies, existing matrix factorization models cannot effectively distinguish these differences. Therefore, this paper proposes a new weighted matrix factorization model to address this issue. The new weighted matrix factorization model achieves the goal of assigning different weights to different data parts by modifying the loss function of the Bias-SVD model. Its loss function contains two parts: one dealing with user historical ratings set \(R_{orig}\) and the other handling the three parts of the predicted ratings set \(R_{pred}\). Both parts of the loss function include a core component representing the difference between the actual value \(r_{ui}\) and the model's predicted value (from Equation (9)) and a regularization part to prevent overfitting, with \(\lambda\) as the regularization coefficient. The specific loss formula is:  
\[ \begin{array}{l}L=\sum_{(u)\in R_{min}}\left[w_{orig}\left(r_{ui}-u-b_{u}-b_{ i}-q_{i}^{T}p_{u}\right)^{2}+\lambda_{1}\left(b_{u}^{2}+b_{i}^{2}\right)+ \lambda_{2}\left(\|q_{i}\|^{2}+\|p_{u}\|^{2}\right)\right]\\ +\sum_{(u)\in R_{pred}}\left[w_{pred}\left(r_{ui}-u-b_{u}-b_{i}-q_{i}^{T}p_{u} \right)^{2}+\lambda_{3}\left(b_{u}^{2}+b_{i}^{2}\right)+\lambda_{4}\left(\|q_ {i}\|^{2}+\|p_{u}\|^{2}\right)\right]\end{array}  \tag{11}\]  
Figure 2: Architecture diagram of the Trust-WMF model. In Equation (11), it is evident that the primary difference between the two parts of the loss function lies in their coefficients. In the model, \(w_{orig}\) represents the weight of the data in the user historical ratings set \(R_{orig}\). Since the original ratings have higher credibility and contain less noise data, the weight \(w_{orig}\) is set to 1. \(w_{pred}\) represents the weight of the data in the predicted ratings set \(R_{pred}\). According to the Trust-WMF model architecture, the predicted ratings set \(R_{pred}\) is composed of three parts: the predicted ratings based on the user's social network, the predicted ratings based on user historical ratings in the matrix, and their overlap. Correspondingly, the model divides \(w_{pred}\) into three parts. The value of \(w_{pred}\) is derived from the following piecewise function:  
\[w_{pred}=\left\{