# Course Recommendation Based on Enhancement of Meta-Path Embedding in Heterogeneous Graph
## 4 Proposed Approach for Course Recommendation
### Matrix Factorization-Based Prediction Layer  
The _MFPL_ module uses Matrix Factorization to predict the grade of students on courses. The HGE-CRec model proposed in this paper combines HG meta-path embedding with Matrix Factorization, and further combines the embedded vectors of users \(u\) and items \(i\) obtained from MEL and EWAL into the Matrix Factorization model. The prediction process of the rating is shown in Equation (9):  
\[\dot{p}_{u,i}=u_{u}^{T}\cdot v_{i}+\alpha\cdot e_{u}^{T}\cdot\gamma_{i}+\beta \cdot\gamma_{u}^{T}\cdot e_{i}, \tag{9}\]  
where \(\dot{p}_{u,i}\), \(u\), and \(i\) belong to the rating matrix \(\mathcal{R}\), \(e_{u}\) is the embedding of the user after merging the embedding vectors of different meta-paths, and \(e_{i}\) is the embedding of the item after merging the embedding vectors of different meta-paths, that is, the result of merging function \(\mathcal{M}(\cdot)\) in Equation (8). In order to keep the form consistent, the hidden factors \(\gamma_{i}\) and \(\gamma_{u}\) are introduced to multiply the embedding vectors \(e_{u}\) and \(e_{i}\), respectively, while \(\alpha\) and \(\beta\) are adjustable parameters. In order to provide the model with better generalization ability and prevent overfitting, regular constraints can be added to the loss function. For modeling scenarios of heterogeneous information networks, heterogeneous regular terms need to be added. The final optimization goal is shown in Equation (10):  
\[ \begin{split}&\ell=\sum_{<u,i,\tau_{u,i}>\in\mathcal{R}}{(r_{u,i}- \dot{p}_{u,i})^{2}+}\\ &\lambda\sum_{u}(\parallel U_{u}\parallel_{2}+\parallel V_{i} \parallel_{2}+\parallel\gamma_{u}\parallel_{2}+\parallel\gamma_{i} \parallel_{2}+\parallel\mathbb{E}_{u}\parallel_{2}+\parallel\mathbb{E}_{i} \parallel_{2}),\end{split}  \tag{10}\]  
where \(\dot{p}_{u,i}\) is the prediction score calculated using Equation (9), \(\lambda\) is the regularization parameter, \(\mathbb{E}_{u}\) is the parameter set of the function \(\mathcal{M}(\cdot)\) for users, and \(\mathbb{E}_{i}\) is the parameter set of the function \(\mathcal{M}(\cdot)\) for items. The model training uses _Gradient Descent_ to obtain the partial derivative, then updates the variables according to the direction of the negative gradient. After multiple iterations, the low-dimensional matrix is updated continuously until the algorithm finally converges; the parameters of Equation (10) are updated according to the following formula:  
\[U_{u}\gets U_{u}-\eta((r_{u,i}-\dot{r}_{u,i})V_{i}+\lambda_{U}U_{u}) \tag{11}\]  
\[\mathbb{E}_{u,l}\leftarrow\mathbb{E}_{u,l}-\eta(-\alpha(r_{u,i}-\dot{r}_{u,i} )\gamma_{u}\
abla^{(U)}+\lambda_{\mathbb{E}}\mathbb{E}_{u,l}), \tag{12}\]  
\[V_{i}\gets V_{i}-\eta((r_{u,i}-\dot{r}_{u,i})U_{u}+\lambda_{V}V_{i}) \tag{13}\]  
\[\mathbb{E}_{i,l}\leftarrow\mathbb{E}_{i,l}-\eta(-\alpha(r_{u,i}-\dot{r}_{u,i} )\gamma_{i}\
abla^{(I)}+\lambda_{\mathbb{E}}\mathbb{E}_{i,l}), \tag{14}\]  
\[\frac{\partial e_{i}^{(l)}}{\partial\mathbb{E}_{i,l}}= \begin{cases}W_{i}^{(l)} \sigma(X_{a})\sigma(X_{f})(1-\sigma(X_{a}))(1-\sigma(X_{f}))e_{i}^{(l)},& \mathbb{E}=M;\\ W_{i}^{(l)}\sigma(X_{a})\sigma(X_{f})(1-\sigma(X_{a}))(1-\sigma(X_{f})),& \mathbb{E}=b;\\ \sigma(X_{a})\sigma(X_{f})(1-\sigma(X_{a})),&\mathbb{E}=W,\end{cases}  \tag{15}\]  
The algorithm for training HGE-CRec is shown in Algorithm 2. ```
0: the heterogeneous graph \(G\); the adjacency matrix \(M^{\alpha}\); the rating matrix \(\mathcal{R}\); the adjustable parameters \(\alpha\), \(\beta\); the regularization parameter \(\lambda\); the learning rate coefficients for integrating embedding features; the enhanced meta-path embedding sets \(\{e_{u}^{(l)}\}_{l}^{|\Gamma^{(U)}|}\) for users and \(\{e_{i}^{(l)}\}_{l}^{|\Gamma^{(U)}|}\) for items.