# Enhanced Collaborative Filtering for Personalized E-Government Recommendation
## 3 Proposed Negative Mixing CF
### Negative Items Sampling  
Recall that the nodes set in the connected graph can be transformed into a metric space by defining the metric function. In this way, the distances can be calculated as the weighted shortest-path distance between two nodes in the graph. In the recommender scenario, the user-item interaction histories can be represented as an undirected graph \(G=(V,E)\) where the nodes set \(V\) are the union of users set \(U\) and items set \(I\) and the edges set \(E\) each of which is composed of a node pair indicating that the user \(u\) interacts with item \(i\) (Figure 3). Therefore, we can calculate the distance between the users and items based on the connectivity of the interaction graph.  
We first define the metric function \(d_{(u,i)}:E\to R\) (each edge is mapped to a real number) for the graph \(G\) based on the auxiliary information (e.g., interaction timestamp) of the feedback and demographic information (e.g., age). Therefore, the weight for \((u,i)\in E\) is  
\[d_{(u,i)}=d_{(i,u)}=\left(f_{(u,i)}(\Delta t,n)-C_{uvv}\right) \tag{1}\]  
\[f_{(u,i)}(\Delta t,n)=\frac{\gamma_{2}(n-N)^{2}+e^{-\gamma_{1}\frac{1}{|\Delta t |}}}{2} \tag{2}\]  
where \(f_{(u,i)}(\Delta t,n)\) evaluates the user \(u^{\prime}\)s preference for item \(i\). Specifically, \(\Delta t\) is the time delay between user \(u^{\prime}\) interaction at timestamp \(t\) and the latest interaction, and \(n\) is the age when user \(u\) first interacted with item \(i\), \(N\) is the mode of users age in the training set, and \(\gamma_{1},\gamma_{2}\) are scale factors. A smaller deviation of age \(n\) from \(N\) or smaller time delay \(\Delta t\) leads to a closer distance between \((u,i)\). \(C_{uv}\) is the average of \(f_{(u,i)}(\Delta t,n)\) overall interaction pairs. Considering the example: for the interaction path \((u_{1}\to i_{1}\to u_{2}\to i_{2})\), the distance between the user \(u_{1}\)and its negative item \(i_{2}\) can be formulated as  
\[d_{(u_{1},i_{2})}=d_{(u_{1},i_{1})}+d_{(i_{1},u_{2})}+d_{(u_{2},i_{2})} \tag{3}\]  
Then we present a negative sampling strategy based on the defined function. For each active interaction pair \((u\,i\ )\), we select the negative items from the interaction pairs set \(H_{(u\,i\ )}\) of which each user is connected to the positive item \(i\). Formally,  
\[H_{(u,i)}=\left\{\left(u^{\prime},i^{\prime}\right)\middle|y_{u^{\prime}i}\ =1,y_{u^{\prime}i^{\prime}}=1,u^{\prime}\
eq u,i^{\prime}\
eq i\right\} \tag{4}\]  
We conform to the following information selection strategy for the learning process:  
* For positive interaction \((u,i)\) and \(H_{(u,i)}\
eq\emptyset\), if the distance value \(d_{(u\,i^{\prime})}\) is less than the given constraint value \(\varepsilon\), the negative item \(i^{\prime}\) is selected to mix with positive item \(i\). The constraint \(\varepsilon\) worked as a 'gate' described in Figure 4.  
Figure 3: Transformation of rating matrix and graph.  
For positive interaction \((u,i)\), \(H_{(u,i)}=\emptyset\), the positive item \(i\) is selected to mix with itself.  
For a negative interaction \((u,i)\), the item \(i\) is also be selected.  
Also, a pseudo code of negative interaction selection for positive interaction is performed in Algorithm 1.