# Neighborhood Aggregation Collaborative Filtering Based on Knowledge Graph
## 3 NACF Framework
### Model Framework Introduction  
The NACF model has four parts of input: the user \(u\in U\), the item \(i\in I\), the user-item interaction matrix \(M\) and the corresponding knowledge graph \(G\). Under the above conditions, NACF discovers the potential interest of users in KG and extracts hidden features between the various entities. Specifically, given the user ID \(u\), the item ID \(i\) and the neighbor set \(N_{e}\) of each entity in the KG, NACF predicts whether \(u\) has potential interest in the \(i\) that \(u\) has not contacted. The user's neighbors of KG is composed of item entities in user-item interaction record. The whole process is to learn the following prediction function:  
\[y(u,i)=F(u,i|w,G_{<E,R>}) \tag{1}\] \begin{table}
\begin{tabular}{c c} \hline \hline
**Symbol** & **Meaning** \\ \hline \(U\)=\(\{u_{1},u_{2},\ldots\}\) & Set of users \\ \(I\)=\(\{i_{1},i_{2},\ldots\}\) & Set of items \\ \(M\) & User-item interaction matrix \\ \(G\)=\([E,R]\) & Knowledge graph \\ \(E_{i}\)\(e_{j},\ldots\) & Set of entities \\ \(R\)=\(\{r_{(i,j)},\ldots\}\) & Set of relations \\ \(e_{j}^{[u]}\) & Entity representation of \(e_{j}\) after the h-th aggregation update \\ \(N_{e_{j}}\) & The direct neighbor set of \(e_{j}\) in KG \\ \(N_{e_{j}}\) & the neighborhood of \(e_{j}\) in \(n\)-_hop_ \\ \(W_{k}^{(u,i)}\) & The aggregate weight of each neighbor entity \(e_{k}\) under a given user-item pair \\ \hline \hline \end{tabular}
\end{table} 
Table 1: List of key symbols. where \(y(u,i)\) represents the probability that user \(u\) will participate in item \(i\), \(F\) represents the recommendation function and \(w\) represents the trainable parameter of \(F\). For each particular user-item pair, the neighbor features of the user are iteratively aggregated onto the entity \(e_{u}\). It includes three steps: neighborhood construction, neighborhood aggregation and prediction. 1. Neighborhood Construction We take into account the entities in _n-hop_ range of KG when extracting the users' features. As shown in Figure 2 left sub-picture, the neighbors in the _1-hop_ range of \(e_{u}\) (\(N_{e_{u}}^{1}\)) are composed of directly connected entities (items with interactive record), the neighbors in the _2-hop_ range (\(N_{e_{u}}^{2}\)) are composed of neighbors of directly connected entities in _1-hop_ and so on. Assuming the _n-hop_ neighbor set of \(e_{u}\) is \(H_{e_{u}}^{n}\), neighborhood construction of \(e_{u}\) is as follows: \[N_{e_{u}}^{n}=\sum_{k=1}^{n}H_{e_{u}}^{k}\] (2) Such a construction method has the obvious advantage that the model expands the physical neighborhood through the KG and can explore the potential interests of the user more broadly and deeply. The range of neighborhood construction has a great impact on the final results of feature extraction. The goal of this step is to find the right range of neighborhood to fully exploit the potential knowledge without introducing too much noise. 2. Neighborhood Aggregation Before neighborhood aggregation, NACF initializes all entities and relations as trainable and random vectors (\(d\)-dimensions). If the neighborhood of entity includes _n-hop_ (\(n\) layers), the aggregation of the entity is iterated \(n\) times in total. In the _h-th_ iteration, all entities in the _n-th_ layer perform aggregation of neighboring information and update the embedding vector. After one aggregation operation is completed, the updated representation of entity comes from the fusion of itself and the neighboring entities. We call such an aggregation operation as sub-aggregation \(Agg\). Until the model is iterated \(n\) times (the knowledge graph neighborhood converges to \(e_{u}\)), the neighborhood aggregation of user is complete. In a \(n\) layer neighborhood, \(e_{u}\) will update a total of _n-1_ times and the final representation of \(e_{u}\) is \(e_{u}^{[n]}\).