# Dynamic Group Recommendation Based on the Attention Mechanism
## 3 Methods
### Improvement  
This algorithm needs to solve two problems: (1) The distance \(d_{ij}\) between different nodes needs to be calculated. In this paper, the similarity between users is taken as the distance between nodes. The similarity distance between user \(i\) and user \(j\) is based on the score of the same item that is determined, and the similarity is calculated as follows:  
\[d_{ij}=\frac{1}{|M|}\ \sum\
olimits_{m\in M}\|s_{m_{i}}-s_{m_{j}}\|, \tag{5}\]  
where \(d_{ij}\) represents the difference distance between user \(i\) and user \(j\), \(s_{m_{i}}\) indicating the score of user \(i\) for item m, similarly \(s_{m_{j}}\) indicating the score of user \(j\) for item m, the set of items graded by both user \(i\) and user \(j\) is represented by M and \(|M|\) denotes the number of elements in the set. The greater the difference between the two users, the farther the distance.  
(2) The calculation of local density \(p_{i}\) and distance \(\delta_{i}\) in DPC depends on the cutoff distance \(d_{c}\). The selection of \(d_{c}\) is based on a manual setting, and the optimal \(d_{c}\) usually needs the experimenter to obtain through many experiments. Whether \(d_{c}\) selection is appropriate or not has a certain influence on the DPC algorithm. If \(d_{c}\) is too large, all data points will be classified into one class in extreme cases, on the other hand, if \(d_{c}\) is too small, all data points become a single class in extreme cases. Since \(d_{c}\) selection is particularly important, in this paper, the \(d_{c}\) to select has made the improvement.  
The vector: \(c_{i}=\{d_{i1},d_{i2},\ldots,d_{in}\}\) where \(d_{ij}\) is the distance between user \(i\) and user \(j\), i.e., similarity, and sorts them in ascending order to get the vector \(f_{i}=\{a_{i1},a_{i2},\ldots,a_{in}\}\), then the cutoff distance of user \(i\) can be defined as:  
\[d_{ci}=a_{ij}\big{|}_{max(a_{i(j+1)}-a_{ij}).} \tag{6}\]  
According to Equation (6), the cutoff distance \(d_{ci}\) of user \(i\) is taken as the maximum value of the difference between two elements of vector \(f_{i}\). Obviously, the distance difference between users belonging to the same cluster is relatively small, whereas the distance difference between users in different clusters is relatively large, as shown in Figure 3.  
Figure 2: (a) Data point distribution and (b) decision diagram.  
Select the \(a_{ij}\) with the largest difference between the two adjacent elements in \(f_{i}\), where \(a_{ij}=a\), \(a_{i(j+1)}=b\) and \(d_{ci}=a_{ij}\big{|}_{max(a_{i(j+1)}-a_{ij})}=a\).  
The equation is still applicable when \(a_{i(j+1)}\) is an outlier. The set \(D_{c}=\{d_{c1},d_{c2},\ldots,d_{cn}\}\) represents the set of \(d_{ci}\) corresponding to each user \(i\). In order to reduce the influence of the points on the cluster boundary and the outliers and avoid excessive \(d_{c}\), \(d_{c}\) should take the minimum value of the set \(D_{c}\), \(\rho_{i}\) and \(\delta_{i}\) should be calculated according to the Equations (1) or (3) and (4), after \(d_{c}\) is determined.  
This method of determining \(d_{c}\) is based on the distance between data objects, so it does not add extra calculation burden and is simple and easy to implement.