# The Use of Attentive Knowledge Graph Perceptual Propagation for Improving Recommendations
## 4 Methodology
### Stratified Sampling and Iterations  
Stratified sampling refers to stratifying a large collection of samples by feature or attribute, and then, randomly sampling each layer. In recommendation systems, the stratified sampling strategy can be used to solve the cold-start problem in migration learning.  
Specifically, suppose there are two domain datasets (A and B). Dataset A contains the historical purchase records and rating information of users, while dataset B does not contain the historical records of users. To solve the cold-start problem in B, we can use the stratified sampling strategy to extract a certain number of samples from A for knowledge migration. The users in dataset A are stratified according to their purchase history or ratings, and then, a certain number of users and products are sampled from each layer, and these samples are used to train the recommendation model; then, the trained model is applied to B for recommendation. This method can retain the characteristics of the samples and avoid sample bias, and can also effectively use the historical data in A to carry out knowledge migration and thus improve the effectiveness of recommendations.  
In this paper, a stratified sampling strategy is proposed. The data obtained by performing aggregated predictions are used as a sample set. The items are divided into multiple groups according to the user's degree of preference for the items. Items with similar preference values are grouped into the same group, and the sum of the preference levels of the samples in each group is the same. Then, the items in each group are identified as positive or negative according to the sample labels. In a similar way to supervised learning, the item characteristics are preserved, and sample bias is avoided when using stratified sampling. Additionally, the learning process of the model is continuously iterated, as shown in Figure 5.  
In order to solve the category imbalance problem, this paper ensures the effect of model training by balancing the number of positive and negative samples, and extracting the same number of negative samples as positive samples for  
Figure 5: Structure diagram of stratified sampling method. The prediction samples obtained from AKGP are first grouped and arranged in descending order according to the preference of the samples. Then, samples with similar preference values are placed in the same group. The sum of the preference levels of samples in each group is the same. Then, the samples in each group are identified as positive or negative according to the sample labels. Finally, the scores are input into the adversarial training loss function, which is iterated into AKPG* model.  
uses cross-entropy as the loss function of the whole AKGP model. The final loss function is as follows.  
\[L=-\sum_{u\in U}\left(\sum_{v\in V}(y_{uv}\text{log}\,\hat{y}_{uv}+(1-y_{uv}) \text{log}(1-\hat{y}_{uv}))\right)+\lambda L_{p} \tag{23}\]  
where \(L_{p}\) denotes a regularization term for the AKGP framework, which is added to the basic loss function to prevent overfitting, and \(\lambda\) is the regularization parameter.