Dynamic Relation-Attentive Graph Neural Networks for Fraud Detection
Fraud detection aims to discover fraudsters deceiving other users by, for
example, leaving fake reviews or making abnormal transactions. Graph-based
fraud detection methods consider this task as a classification problem with two
classes: frauds or normal. We address this problem using Graph Neural Networks
(GNNs) by proposing a dynamic relation-attentive aggregation mechanism. Based
on the observation that many real-world graphs include different types of
relations, we propose to learn a node representation per relation and aggregate
the node representations using a learnable attention function that assigns a
different attention coefficient to each relation. Furthermore, we combine the
node representations from different layers to consider both the local and
global structures of a target node, which is beneficial to improving the
performance of fraud detection on graphs with heterophily. By employing dynamic
graph attention in all the aggregation processes, our method adaptively
computes the attention coefficients for each node. Experimental results show
that our method, DRAG, outperforms state-of-the-art fraud detection methods on
real-world benchmark datasets.
Heehyeon Kim, Jinhyeok Choi, Joyce Jiyoung Whang
# Dynamic Relation-Attentive Graph Neural Networks for Fraud Detection

###### Abstract

Fraud detection aims to discover fraudsters deceiving other users by, for example, leaving fake reviews or making abnormal transactions. Graph-based fraud detection methods consider this task as a classification problem with two classes: frauds or normal. We address this problem using Graph Neural Networks (GNNs) by proposing a dynamic relation-attentive aggregation mechanism. Based on the observation that many real-world graphs include different types of relations, we propose to learn a node representation per relation and aggregate the node representations using a learnable attention function that assigns a different attention coefficient to each relation. Furthermore, we combine the node representations from different layers to consider both the local and global structures of a target node, which is beneficial to improving the performance of fraud detection on graphs with heterophily. By employing dynamic graph attention in all the aggregation processes, our method adaptively computes the attention coefficients for each node. Experimental results show that our method, DRAG, outperforms state-of-the-art fraud detection methods on real-world benchmark datasets.

 fraud detection, graph anomaly detection, graph neural networks, relation attentive, dynamic attention

## I Introduction

Graph-based fraud detection methods, also called graph anomaly detection methods, represent objects that should be determined to be fraud or benign as nodes and make edges between them [1, 2]. For example, in YelpChi benchmark dataset [3], nodes are reviews and edges are created based on three different factors: (1) whether the reviews were written by the same user, (2) whether the reviews were written in the same month, and (3) whether the reviews had the same star rating. Each of these three factors can be considered as a different relation since their semantics are distinct [4].

Several recently proposed fraud detection methods distinguish different relations in computing node representations [5, 6, 7, 8, 9, 10]. For example, CARE-GNN [11] uses a relation-aware neighbor aggregator and BWGNN [12] performs a propagation process for each relation and apply a maximum pooling. Also, FRAUDRE [13] learns the fraud-aware graph convolution model under each relation. In general, these relation-aware approaches have shown superior performance over the methods that ignore relations and consider all edges equally [14, 15].

In this paper, we propose DRAG which is a Dynamic Relation-Attentive Graph neural network (Figure 1), which decomposes the original graph by relations to learn a node representation per relation along with a self-transformation, resulting in multiple representations for each node. We consider the self-loop used in self-transformation as another relation. At each layer, DRAG aggregates the multiple representations for each node with different learnable attention weights for the relations. The final representation is computed by aggregating representations from different layers, where not only the last layer's representation but also intermediate layers' representations are taken into account. In all these processes, we employ a dynamic graph attention mechanism [16] to let DRAG have various distributions of attention coefficients, which can differ for each node. Experimental results on real-world datasets show that DRAG outperforms eight different baseline methods. Our implementations and datasets are available at [https://github.com/bdi-lab/DRAG](https://github.com/bdi-lab/DRAG).

**Related Work:** In the original GAT [17], the static attention problem has been issued, a phenomenon in which all nodes have a fixed ranking of attention coefficients. To resolve this issue, GATv2 [16] has been proposed by introducing a dynamic attention, which swaps the order of operations of applying a linear projection layer and the non-linear function. On the other hand, WIRGAT [18] has been proposed to compute relation-wise representations for each node using a static attention and simply sum over the node representations. Different from DRAG, none of these methods considers dynamic relation-attentive and layer-attentive aggregations.

Heterophily in graphs has been considered as a challenging issue in graph-based fraud detection [19, 20, 21] since nodes are connected to other nodes belonging to a different class. DRAG alleviates this issue by learning attention coefficients, which weigh the importance of each neighbor regarding computing the representation of the target node. More importantly, these attention coefficients can vary depending on each target node since we utilize the dynamic attention mechanism.
## II Problem Definition

Let us consider an undirected multi-relation graph \(G=(\mathcal{V},\mathcal{R},\mathcal{E},\mathbf{X})\) where \(\mathcal{V}\) is a set of nodes, \(\mathcal{R}\) is a set of relations, \(|\mathcal{V}|=n\), \(|\mathcal{R}|=m\), \(\mathcal{E}=\{(v_{i},r_{k},v_{j})|v_{i}\in\mathcal{V},r_{k}\in\mathcal{R},v_{j} \in\mathcal{V}\}\), \(\mathbf{X}\in\mathbb{R}^{n\times d}\) is a set of features for the nodes, and \(d\) is the dimension of each feature vector. There can be multiple edges between a pair of nodes if they have different relations. For example, given \(v_{i}\) and \(v_{j}\), \(\mathcal{E}\) can include both \((v_{i},r_{k},v_{j})\) and \((v_{i},r_{k^{\prime}},v_{j})\). Each node is labeled as a normal node or a fraudulent node. Let \(\mathbf{y}\in\{0,1\}^{n}\) denote a vector for the labels such that \(y_{i}=1\) if the \(i\)-th node is a fraud and \(y_{i}=0\) otherwise.

## III DRAG: Dynamic Relation-Attentive Graph Neural Network

We describe DRAG which computes node representations using relation-wise and layer-wise dynamic attention mechanisms.

### _Node Representation per Relation and Self-Transformation_

We propose learning multiple node representations for each node by computing a representation per relation and a self-transformation. To appropriately compute an attention coefficient [17], we add a self-loop to each node for all relations. The neighborhood set of \(v_{i}\) for \(r_{k}\) is defined by \(\mathcal{N}_{ik}\coloneqq\{v_{j}|(v_{j},r_{k},v_{i})\in\mathcal{E}\}\) where \(i=1,\cdots,n\) and \(k=1,\cdots,m\). The node representation of \(v_{i}\) for \(r_{k}\) at the \(l\)-th layer is denoted by \(\mathbf{h}_{i,k}^{(l)}\in\mathbb{R}^{d^{\prime}}\) where \(d^{\prime}\) is the dimension of the node representation. Let \(\mathbf{h}_{i}^{(l)}\in\mathbb{R}^{d^{\prime}}\) be the node representation of \(v_{i}\) at the \(l\)-th layer. We compute \(\mathbf{h}_{i}^{(0)}=\text{MLP}(\mathbf{x}_{i})\) for \(v_{i}\in\mathcal{V}\) where MLP is a multi-layer perceptron. Using the dynamic multi-head attention [16] with \(N_{\alpha}\) heads, we compute the node representation for \(r_{k}\) at each head as follows:

\[\mathbf{h}_{i,k}^{(l)}=\sigma\left(\sum_{v_{j}\in\mathcal{N}_{ik}}\alpha_{ijk }^{(l)}\mathbf{P}_{k}^{(l)}\mathbf{h}_{j}^{(l)}\right) \tag{1}\]

where \(\mathbf{P}_{k}^{(l)}\in\mathbb{R}^{(d^{\prime}/N_{\alpha})\times d^{\prime}}\) and \(\alpha_{ijk}^{(l)}\) is computed by

\[\alpha_{ijk}^{(l)}=\frac{\text{exp}\left(\mathbf{a}_{k}^{(l)}\sigma\left(\bm {W}_{k}^{(l)}|\mathbf{h}_{i}^{(l)}||\ \mathbf{h}_{j}^{(l)}|\right)\right)}{\sum_{v_{j^{\prime}}\in\mathcal{N}_{ik}} \text{exp}\left(\mathbf{a}_{k}^{(l)}\sigma\left(\mathbf{W}_{k}^{(l)}|\mathbf{h}_{i }^{(l)}||\ \mathbf{h}_{j^{\prime}}^{(l)}|\right)\right)} \tag{2}\]

where \(||\) denotes a vertical concatenation, \(\mathbf{W}_{k}^{(l)}\in\mathbb{R}^{d^{\prime}\times 2d^{\prime}}\), \(\mathbf{a}_{k}^{(l)}\in\mathbb{R}^{d^{\prime}}\), \(\sigma(\cdot)\) is a non-linear function, \(l=0,1,\cdots,L\), and \(L\) is the total number of layers. To aggregate the outputs from \(N_{\alpha}\) heads, we concatenate the resulting representations from different heads [22]; as a result, we have \(\mathbf{h}_{i,k}^{(l)}\in\mathbb{R}^{d^{\prime}}\). We apply the same concatenation strategy to aggregate results from multi-head outputs in all following attention mechanisms.

By computing a node representation per relation using (1), we have \(m\) representations for each node. We also compute the (\(m+1\))-th representation for a node by considering a self-transformation: \(\mathbf{h}_{i,m+1}^{(l)}=\text{MLP}\left(\mathbf{h}_{i}^{(l)}\right)\) where \(\mathbf{h}_{i,m+1}^{(l)}\in\mathbb{R}^{d^{\prime}}\).

### _Relation-Attentive Aggregation_

For each node, we have (\(m\)+1) representations at each layer as described above. DRAG aggregates these representations using a dynamic attention with \(N_{\beta}\) attention heads:

\[\mathbf{h}_{i}^{(l+1)}=\sigma\left(\sum_{k=1}^{m+1}\beta_{ik}^{(l)}\overline{ \mathbf{P}}^{(l)}\mathbf{h}_{i,k}^{(l)}\right) \tag{3}\]

where \(\overline{\mathbf{P}}^{(l)}\in\mathbb{R}^{(d^{\prime}/N_{\beta})\times d^{\prime}}\) and \(\beta_{ik}^{(l)}\) is computed by

\[\beta_{ik}^{(l)}=\frac{\text{exp}\left(\overline{\mathbf{a}}^{(l)}\sigma\left( \overline{\mathbf{W}}^{(l)}|\mathbf{h}_{i}^{(l)}||\ \mathbf{h}_{i,k}^{(l)}|\right)\right)}{\sum_{k^{\prime}=1}^{m+1}\text{exp} \left(\overline{\mathbf{a}}^{(l)}\sigma\left(\overline{\mathbf{W}}^{(l)}|\mathbf{h} _{i}^{(l)}||\ \mathbf{h}_{i,k^{\prime}}^{(l)}|\right)\right)} \tag{4}\]

where \(\overline{\mathbf{W}}^{(l)}\in\mathbb{R}^{d^{\prime}\times 2d^{\prime}}\), and \(\overline{\mathbf{a}}^{(l)}\in\mathbb{R}^{d^{\prime}}\) for \(l=0,1,\cdots,L\). The attention coefficient \(\beta_{ik}^{(l)}\) indicates the importance of the \(k\)-th relation for computing the representation of \(v_{i}\) at the \(l\)-th layer. This attention coefficient can differ depending on nodes and layers.

Fig. 1: Overview of DRAG. A node representation is computed by each relation and by a self-transformation. Using learnable attention weights, the node representations are aggregated over the relations. The final node representation is learned by aggregating the representations from different layers and used to predict whether the node is a fraud.
### _Aggregation with Multiple Layers_

It has been known that, when solving a node classification problem under heterophily [19], it is helpful to explicitly consider the local and global neighbors by combining intermediate representations [23]. To leverage this property, we aggregate representations from different layers:

\[\mathbf{h}_{i}^{(L+1)}=\sigma\left(\sum_{l=0}^{L}\boldsymbol{\gamma}_{il} \widetilde{\boldsymbol{P}}\mathbf{h}_{i}^{(l)}\right) \tag{5}\]

with \(N_{\gamma}\) heads, where \(\widetilde{\boldsymbol{P}}\in\mathbb{R}^{(d^{\prime}/N_{\gamma})\times d^{ \prime}}\), \(\mathbf{h}_{i}^{(L+1)}\in\mathbb{R}^{d^{\prime}}\) is the final representation of \(v_{i}\), and \(\boldsymbol{\gamma}_{il}\) is computed by

\[\boldsymbol{\gamma}_{il}=\frac{\text{exp}\left(\widetilde{\mathbf{a}}\ \sigma\left(\widetilde{\boldsymbol{W}}[\mathbf{x}_{i}\ ||\ \mathbf{h}_{i}^{(l)}]\right)\right)}{\sum_{l^{\prime}=0}^{L}\text{exp} \left(\widetilde{\mathbf{a}}\ \sigma\left(\widetilde{\boldsymbol{W}}[\mathbf{x}_{i}\ ||\ \mathbf{h}_{i}^{(l^{\prime})}]\right)\right)} \tag{6}\]

where \(\widetilde{\boldsymbol{W}}\in\mathbb{R}^{d^{\prime}\times(d+d^{\prime})}\) and \(\widetilde{\mathbf{a}}\in\mathbb{R}^{d^{\prime}}\). Note that the attention coefficient \(\boldsymbol{\gamma}_{il}\) is learned to imply the importance of the \(l\)-th layer's representation for computing the final representation of node \(v_{i}\).

### _Loss Function of_ DRAG

Using the final representation of each node, we predict the node label by computing \(\widehat{y}_{i}=\text{MLP}\left(\mathbf{h}_{i}^{(L+1)}\right)\), where \(\widehat{y}_{i}\) indicates \(v_{i}\)'s probability of being a fraud. The loss function of DRAG is defined by \(\mathcal{L}_{\text{DRAG}}=\sum_{v_{i}\in\mathcal{S}}-y_{i}\text{log}\left( \widehat{y}_{i}\right)\) where \(\mathcal{S}\subset\mathcal{V}\) is a training set.

## IV Experiments

We compare the performance of DRAG with state-of-the-art fraud detection methods using real-world datasets.

### _Datasets and Experimental Setup_

To test a performance of a fraud detection method, we assume that we observe \(p\%\) of the node labels and use them as a training set. Following a conventional setting [12], we divide the remaining nodes into a validation set and a test set with a ratio of 1:2. We use two well-known real-world datasets, YelpChi [3] and Amazon [24, 25]. In these datasets, there exist three different relations as shown in Table II, where ALL indicates the total number of edges disregarding relations. Note that multiple edges between two nodes resulting from different relations are counted as one edge in ALL. In Amazon, we found that there are 2,104 duplicated nodes that do not have unique features. Since these nodes occur a data leaking issue, we removed these nodes.1

Footnote 1: In Amazon, the features include the feedback summary length, the entropy of ratings, the length of the username, and the ratio of helpful votes [25]; the combination of these features should distinguish a node. It is very unlikely that multiple nodes share identical features, and thus we believe the duplicated nodes should be removed.

We consider the following eight different baseline methods: MLP, GraphSAGE [26], GAT [17], GATv2 [16], FRAUDE [13], CARE-GNN [11], PC-GNN [27], and

\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline  & \#Nodes & \#Frauds & Relation & \#Edges & \(d\) \\ \hline \multirow{3}{*}{Yelp\_Chi_} & \multirow{3}{*}{45,954} & \multirow{3}{*}{6,677 (14.53\%)} & R-U-R & 49,315 & \\  & & & R-T-R & 573,616 & \\  & & & R-S-R & 3,402,743 & \\ \cline{3-6}  & & & ALL & 3,846,979 & \\ \hline \multirow{3}{*}{Amazon} & \multirow{3}{*}{9,840} & \multirow{3}{*}{821 (8.34\%)} & U-P-U & 150,917 & \multirow{3}{*}{25} \\  & & U-S-U & 297,9223 & & \\ \cline{1-1}  & & U-V-U & 838,682 & & \\ \cline{1-1}  & & & ALL & 3,627,491 & \\ \hline \hline \end{tabular}
\end{table} TABLE II: Dataset Statistic.

\begin{table}
\begin{tabular}{c c|c c|c c|c c} \hline \hline  & & \multicolumn{2}{c|}{1\%} & \multicolumn{2}{c|}{10\%} & \multicolumn{2}{c}{40\%} \\  & & F1-macro & AUC & F1-macro & AUC & F1-macro & AUC \\ \hline \multirow{6}{*}{YelpChi} & MLP & 0.6150\(\pm\)0.0072 & 0.7253\(\pm\)0.0098 & 0.6720\(\pm\)0.0069 & 0.8010\(\pm\)0.0053 & 0.7140\(\pm\)0.0048 & 0.8489\(\pm\)0.0064 \\  & GraphSAGE & 0.6269\(\pm\)0.0107 & 0.7363\(\pm\)0.0145 & 0.6971\(\pm\)0.0074 & 0.8293\(\pm\)0.0058 & 0.7456\(\pm\)0.0078 & 0.8800\(\pm\)0.0061 \\  & GAT & 0.6183\(\pm\)0.0133 & 0.7188\(\pm\)0.0176 & 0.6763\(\pm\)0.0089 & 0.7970\(\pm\)0.0118 & 0.7190\(\pm\)0.0085 & 0.8492\(\pm\)0.0087 \\  & GATv2 & 0.6283\(\pm\)0.0109 & 0.7366\(\pm\)0.0129 & 0.6938\(\pm\)0.0077 & 0.8204\(\pm\)0.0060 & 0.7524\(\pm\)0.0098 & 0.8804\(\pm\)0.0067 \\  & FRAUDE & 0.5868\(\pm\)0.0208 & 0.7232\(\pm\)0.0182 & 0.6236\(\pm\)0.0178 & 0.7773\(\pm\)0.01040 & 0.6367\(\pm\)0.0136 & 0.8107\(\pm\)0.0197 \\  & CARE-GNN & 0.6151\(\pm\)0.0119 & 0.7290\(\pm\)0.0133 & 0.6859\(\pm\)0.0302 & 0.8223\(\pm\)0.0223 & 0.6943\(\pm\)0.0150 & 0.8316\(\pm\)0.0113 \\  & PC-GNN & 0.6335\(\pm\)0.0154 & 0.7412\(\pm\)0.0184 & 0.6950\(\pm\)0.0112 & 0.8239\(\pm\)0.0093 & 0.7202\(\pm\)0.0125 & 0.8495\(\pm\)0.0138 \\  & BWGNN-Homo & 0.5797\(\pm\)0.0183 & 0.7016\(\pm\)0.0213 & 0.6316\(\pm\)0.0280 & 0.7772\(\pm\)0.0173 & 0.6425\(\pm\)0.0604 & 0.8515\(\pm\)0.0103 \\  & BWGNN-Hetero & 0.6558\(\pm\)0.0118 & 0.7764\(\pm\)0.0196 & 0.7137\(\pm\)0.0197 & 0.8455\(\pm\)0.0146 & 0.7176\(\pm\)0.0705 & 0.9026\(\pm\)0.0105 \\  & DRAG (Ours) & **0.6884\(\pm\)0.0094** & **0.8279\(\pm\)0.0100** & **0.7462\(\pm\)0.0076** & **0.8833\(\pm\)0.0056** & **0.7988\(\pm\)0.0067** & **0.9233\(\pm\)0.0053** \\ \hline \multirow{6}{*}{Amazon} & MLP & **0.9069\(\pm\)0.0084** & 0.9120\(\pm\)0.0241 & **0.9044\(\pm\)0.0083** & 0.9524\(\pm\)0.0101 & 0.9114\(\pm\)0.0073 & 0.9695\(\pm\)0.0038 \\  & GraphSAGE & 0.8999\(\pm\)0.0108 & 0.9095\(\pm\)0.0193 & 0.8966\(\pm\)0.0095 & **0.9549\(\pm\)0.0092** & 0.9123\(\pm\)0.0065 & **0.9741\(\pm\)0.0031** \\ \cline{1-1}  & GAT & 0.8685\(\pm\)0.0303 & 0.9126\(\pm\)0.0177 & 0.8874\(\pm\)0.0115 & 0.9475\(\pm\)0.0127 & 0.9023\(\pm\)0.0071 & 0.9640\(\pm\)0.0144 \\ \cline{1-1}  & GATv
BWGNN [12]. We use the official implementations of these methods and the hyperparameters provided in the code or in the original paper. In DRAG, we search the hyperparameters by considering the learning rate in \(\{0.01,0.001\}\), the weight decay in \(\{0.001,0.0001\}\), \(L\in\{1,2,3\}\), the number of heads in \(\{2,8\}\). We fix the batch size to be 1,024 and \(d^{\prime}=64\) for all experiments. For all methods, we set the dimension of the final node representation to 64 and max epochs to 1,000 for fair comparisons.

### _Fraud Detection Performance_

In Table I, we show the fraud detection performance of the methods with different \(p\in\{1,10,40\}\) in terms of two standard metrics, F1-macro and AUC. F1-macro is the unweighted mean of the F1 scores of two classes. AUC is the area under the ROC curve, representing the true positive rate against the false positive rate at various thresholds. We repeat all experiments ten times and report the average and the standard deviation. The best performance is boldfaced, and the second-best performance is underlined. In YelpChi, we see that DRAG significantly outperforms the baseline methods in all settings; DRAG shows the best performance in terms of both F1-macro and AUC with three different ratios of labels. In Amazon, DRAG shows comparable performance to the best-performing method.

### _Qualitative Analysis & Ablation Studies_

As described in Section III-B, DRAG learns \(\beta_{ik}^{(l)}\) which indicates the importance of \(r_{k}\) to \(v_{i}\) at the \(l\)-th layer. Figure 2 shows the kernel density estimate plots of \(\beta_{ik}^{(l)}\) values at each layer in YelpChi with \(L=2\) and Amazon with \(L=3\). We see that each relation has a distinguishing distribution of the attention coefficients, which also differs between layers. Also, DRAG learns \(\gamma_{il}\) indicating the importance of the \(l\)-th layer representation for \(v_{i}\) as described in Section III-C. Figure 3 shows the distributions of \(\gamma_{il}\). While Layer-2 tends to have a large importance in YelpChi, Layer-0 has a relatively large importance in Amazon. In Figure 2 and Figure 3, we see that the attention coefficient values are not concentrated on specific values, and some of their distributions are multimodal. This shows that our dynamic graph attention mechanism works as expected, resulting in various attention coefficients depending on target nodes.

We conduct ablation studies by disregarding relation types (w/o rel. types), by removing the layer aggregation (w/o layer agg.), and by utilizing only a single layer instead of multiple layers (w/ single layer) in DRAG as presented in Table III. We see that the performance of DRAG significantly degrades by dropping either the relation-attentive aggregation or the layer-attentive aggregation, which indicates that both of these play a critical role in DRAG. In addition, we observe that considering higher-order neighbors via multiple layers helps increase fraud detection performance, mainly when enough labels are provided.

## V Conclusion & Future Work

We propose a dynamic attention-based fraud detection, performing relation-wise and layer-wise attentive aggregations. The learnable attention coefficients allow DRAG to concentrate more on neighbors, relations, and layers beneficial to predict the label of the target node. By dynamically adapting the attention coefficients for individual nodes, this attention

Fig. 3: \(\gamma_{il}\) attention coefficients in YelpChi and Amazon.

\begin{table}
\begin{tabular}{c|c c c} \hline  & 1\% & 10\% & 40\% \\ \hline DRAG & 0.8279\(\pm\)0.0100 & 0.8833\(\pm\)0.0056 & 0.9233\(\pm\)0.0053 \\ w/o rel. types & 0.7200\(\pm\)0.0134 & 0.8079\(\pm\)0.0134 & 0.8716\(\pm\)0.0054 \\ w/o layer agg. & 0.7153\(\pm\)0.1349 & 0.8377\(\pm\)0.1128 & 0.8775\(\pm\)0.1260 \\ w/ single layer & 0.8214\(\pm\)0.0085 & 0.8790\(\pm\)0.0085 & 0.9076\(\pm\)0.0087 \\ \hline \end{tabular}
\end{table} TABLE III: Ablation studies of DRAG. AUC scores on YelpChi using different percentages of labels are reported.

Fig. 2: The kernel density estimate plots of \(\beta_{ik}^{(l)}\) attention coefficients at each layer in YelpChi (\(L=2\)) and Amazon (\(L=3\)).
mechanism is especially effective in fraud detection on graphs with heterophily.

In future work, we will investigate our attention mechanisms from a theoretical point of view. Specifically, we will explore how the attention coefficients are learned under a specific heterophily property. Moreover, we plan to extend our approaches and methods to more complex relational graphs [28, 29]. Also, we will extend DRAG to handle evolving graphs where new nodes appear and new edges are formed over time [30].
