# Weighted Matrix Factorization Recommendation Model Incorporating Social Trust
## 4 Trust-Based Weighted Matrix Factorization  
### Bias-SVD Matrix Factorization  
The core concept of matrix factorization is to map users and items into a common k-dimensional latent space. In this space, the interactions between users and items can be modeled using the inner product of vectors. Using this method, matrix factorization can capture latent patterns and relationships in the data, enabling the model to predict unknown user-item ratings.  
Funk-SVD [24] is one of the earliest matrix factorization models used for sparse matrices. It decomposes an \(m\times n\) matrix \(R_{m\times n}\) into a user-related matrix \(P_{m\times k}\) and an item-related matrix \(Q_{k\times n}\):  
\[R_{m\times n}\approx P_{m\times k}Q_{k\times n}^{T} \tag{6}\]  
Through matrix factorization, user \(u\) obtains a feature vector \(p_{u}\) representing their preferences, and item \(i\) obtains a feature vector \(q_{i}\) representing its characteristics. Then, the predicted rating of item \(i\) by user \(u\) is calculated as the product of the feature vector \(p_{u}\) of the user and the feature vector \(q_{i}\) of the item:  
\[p_{ui}=q_{i}^{T}p_{u} \tag{7}\]The core of matrix factorization is the optimization process, which aims to find the optimal \(P_{m\times k}\) and \(Q_{k\times n}^{T}\) such that their product approximates the actual rating data \(R_{m\times n}\) as closely as possible. This is typically achieved by minimizing a loss function. The loss function for Funk-SVD is:  
\[L=\sum\
olimits_{(u,i)\in R}\left(r_{ui}-q_{i}^{T}p_{u}\right)^{2}+\lambda \left(\|q_{i}\|^{2}+\|p_{u}\|^{2}\right) \tag{8}\]  
where \(r_{ui}\) represents the actual rating of user \(u\) for item \(i\), and \(q_{i}^{T}p_{u}\) (derived from Equation (7)) represents the predicted rating of user \(u\) for item \(i\). The first part of the loss function represents the mean squared error between the model's predictions and the actual values, which is the core of the loss function. By minimizing this part, the prediction accuracy of the model can be directly optimized. The latter part of the loss function represents the regularization term. The regularization term imposes a penalty on the magnitude of the feature vectors, helping to control the complexity of the model. This can prevent overfitting on the training data, thereby improving the model's generalization ability on unseen data. The regularization coefficient \(\lambda\) can be adjusted to control the degree of penalty on model complexity. A larger \(\lambda\) strengthens the penalty on model complexity, helping to reduce the risk of overfitting, but it may also lead to underfitting.  
Then, the loss function is optimized using gradient descent, continuously adjusting the feature matrices to reduce the difference between predicted and actual ratings.  
In practice, different users have varying standards for rating, and the quality of different items also varies. Factors that are unrelated to a user's preference for an item but depend on the inherent characteristics of the user or the item are referred to as biases.  
Bias-SVD [5] extends the Funk-SVD model by incorporating bias terms. This modification alters the prediction formula from the previous \(q_{i}^{T}p_{u}\) to the following:  
\[\hat{p}_{ui}=u+b_{u}+b_{i}+q_{i}^{T}p_{u} \tag{9}\]  
In this modified formula, \(u\) represents the overall rating situation in the training data, typically set as the mean of the ratings in the training dataset. The value of u may vary depending on the rating habits of users in different datasets. \(b_{u}\) and \(b_{i}\) represent the biases of the user and the item, respectively. These biases are parameters that need to be trained.  
The loss function for Bias-SVD also changes to:  
\[L=\sum\
olimits_{(u,i)\in R}\left(r_{ui}-u-b_{u}-b_{i}-q_{i}^{T}p_{u}\right)^ {2}+\lambda\left(b_{u}^{2}+b_{i}^{2}+\|q_{i}\|^{2}+\|p_{u}\|^{2}\right) \tag{10}\]