# Review Rating Prediction Based on User Context and Product Context
## 3 RRP Based on User Context and Product Context
### RRP Based on Review Content and Product Context  
Due to the differences in sentiment expression of different products in reviews, the general RRP model that is built for all products cannot accurately understand the special sentiment expression of each product. It is the most intuitive method to design a personalized RRP method for each product by using the personal review content published for each product. However, the personal review data published for a single product is usually very limited. Therefore, based on the personal review data alone, it is impossible to accurately train a RRP model for each product.  
Although each product has its own unique sentiment expression, different products have many identical sentiment expressions. For example, general sentiment words such as \"perfect\", \"excellent\", and \"bad\" often express a constant sentiment tendency in different products. Therefore, making full use of the shared sentiment information between different products can help to solve the problem of insufficient data for a single product.  
Based on the above analysis, we propose a RRP model based on the review content and product context. In order to model the sentiment commonality of different products and sentiment specific of individual product, the RRP model is decomposed into two components, a common one and a product-specific one. The common part is shared by all products to characterize the sentiment information shared by different products and to use all product data for training. The product-specific part is unique to each product and it is used to characterize each product-specific sentiment expression and to use a single product's data for learning.  
Specifically, user \(u\) has posted a review \(\mathbf{r}_{ui}\) on the item \(i\). The RRP model that is based on the review content and product context is as followed:  
\[\hat{v}_{ui}=\left(\mathbf{w}+\mathbf{w}_{i}\right)^{\mathrm{T}}\mathbf{r}_{ui} \tag{6}\]  
Here, \(\hat{v}_{ui}\) is the predicted rating of user \(u\) for item \(i\); \(\mathbf{w}\) and \(\mathbf{w}_{i}\) are the common and product-specific parameters in RRP model; and, \(\mathbf{r}_{ui}\) is the vector representation of review content.  
To calculate the parameter vector \(\mathbf{w}\) and \(\mathbf{w}_{i}\), given the training data set and, we use the least squares error loss principle to minimize the objective function in training data set.  
\[\underset{\mathbf{w},\mathbf{w}_{i}}{\text{min}}\underset{\text{transsets}}{ \sum}\left(v_{ui}-\left(\mathbf{w}+\mathbf{w}_{i}\right)^{\mathrm{T}}\mathbf{ r}_{ui}\right)^{2}+\lambda\Big{(}\|\mathbf{w}\|^{2}+\|\mathbf{w}_{i}\|^{2} \Big{)} \tag{7}\]  
Here, \(\lambda\) is the regular coefficient, \(|\ |\ \mathbf{w}\ |\ |\) and \(|\ |\ \mathbf{w}_{i}\ |\) are the regular term of the parameter vector \(\mathbf{w}\) and \(\mathbf{w}_{i}\). To estimate the parameter vector \(\mathbf{w}\) and \(\mathbf{w}_{i}\), we use a stochastic gradient descent algorithm to solve this optimization problem. We use the following update rules to learn the parameters \(\mathbf{w}\) and \(\ \mathbf{w}_{i}\).  
\[\mathbf{w}\leftarrow\mathbf{w}+\eta(\varepsilon_{ui}\mathbf{r}_{ui}-\lambda \mathbf{w}) \tag{8}\]  
\[\mathbf{w}_{i}\leftarrow\mathbf{w}_{i}+\eta(\varepsilon_{ui}\mathbf{r}_{ui}- \lambda\mathbf{w}_{i}) \tag{9}\]  
Here, \(\varepsilon_{ui}=v_{ui}-\left(\mathbf{w}+\mathbf{w}_{i}\right)^{\mathrm{T}} \mathbf{r}_{ui}\), \(\eta\) is learning rate. After getting \(\mathbf{w}\) and \(\mathbf{w}_{i}\), given reviews in test datasets, we can use \(\hat{v}_{ui}=\left(\mathbf{w}+\mathbf{w}_{i}\right)^{\mathrm{T}}\mathbf{r}_{ui}\) to predict the review rating.