Transaction Fraud Detection via an Adaptive Graph Neural Network
Many machine learning methods have been proposed to achieve accurate
transaction fraud detection, which is essential to the financial security of
individuals and banks. However, most existing methods leverage original
features only or require manual feature engineering. They lack the ability to
learn discriminative representations from transaction data. Moreover, criminals
often commit fraud by imitating cardholders' behaviors, which causes the poor
performance of existing detection models. In this paper, we propose an Adaptive
Sampling and Aggregation-based Graph Neural Network (ASA-GNN) that learns
discriminative representations to improve the performance of transaction fraud
detection. A neighbor sampling strategy is performed to filter noisy nodes and
supplement information for fraudulent nodes. Specifically, we leverage cosine
similarity and edge weights to adaptively select neighbors with similar
behavior patterns for target nodes and then find multi-hop neighbors for
fraudulent nodes. A neighbor diversity metric is designed by calculating the
entropy among neighbors to tackle the camouflage issue of fraudsters and
explicitly alleviate the over-smoothing phenomena. Extensive experiments on
three real financial datasets demonstrate that the proposed method ASA-GNN
outperforms state-of-the-art ones.
Yue Tian, Guanjun Liu, Jiacun Wang, Mengchu Zhou
# Transaction Fraud Detection via an Adaptive Graph Neural Network

###### Abstract

Many machine learning methods have been proposed to achieve accurate transaction fraud detection, which is essential to the financial security of individuals and banks. However, most existing methods leverage original features only or require manual feature engineering. They lack the ability to learn discriminative representations from transaction data. Moreover, criminals often commit fraud by imitating cardholders' behaviors, which causes the poor performance of existing detection models. In this paper, we propose an Adaptive Sampling and Aggregation-based Graph Neural Network (ASA-GNN) that learns discriminative representations to improve the performance of transaction fraud detection. A neighbor sampling strategy is performed to filter noisy nodes and supplement information for fraudulent nodes. Specifically, we leverage cosine similarity and edge weights to adaptively select neighbors with similar behavior patterns for target nodes and then find multi-hop neighbors for fraudulent nodes. A neighbor diversity metric is designed by calculating the entropy among neighbors to tackle the camouflage issue of fraudsters and explicitly alleviate the over-smoothing phenomena. Extensive experiments on three real financial datasets demonstrate that the proposed method ASA-GNN outperforms state-of-the-art ones.

 Graph neural network, transaction fraud, weighted multigraph, attention mechanism, entropy.

## I Introduction

Online transaction is a popular and convenient way of electronic payment. It also increases the incidences of financial fraud and causes massive monetary losses to individuals and banks. The global losses reached 25 billion dollars in 2018 and have kept increasing [1]. According to statistics from Nilson Report, the losses jumped to 28.65 billion in 2020 [2]. Financial institutions have taken measures to prevent fraud. In traditional methods, online transactions are checked against some expert rules, and then suspicious transactions are fed to a detection model. The task of the detection model is to mine fraud patterns (represented as some rules) from sizeable historical transaction data so that the model can find transactions that match these rules. However, the ability of these rules is limited and hardly adapts to the fast changes in fraud patterns.

How to quickly mine and represent as many fraud patterns as possible and fit their changes is complicated since fraudsters and detectors of fraud transactions have kept a dynamic gaming process for a long time [3]. Transaction records often contain transaction-related elements, such as location, date, time, and relations. Although there are machine learning-based methods to detect fraudulent transactions, most require manual feature engineering based on the above elements and the construction of supervised classifiers [4, 5]. These methods fail to automatically detect fraud patterns and express important behavior information [6]. On the one hand, there are many interactions among transactions [7]. On the other hand, the transaction behaviors of users are dynamic [8]. Hence, designing a more discriminative representation framework for transaction fraud detection remains a big challenge. The camouflage of fraudsters is another challenge that causes performance degradation and poor generalization of many detection approaches [9].

Recently, graph neural networks (GNNs) have been used to learn representations automatically for some prediction tasks [10, 11, 12]. In contrast to traditional machine learning methods, GNN utilizes a neighborhood aggregation strategy to learn representations and then uses a neural network for node classification and link prediction [13]. These methods can capture rich interactions among samples and avoid feature engineering [9]. However, learning discriminative representations by directly applying these graph techniques to our transaction fraud detection problem is challenging. They ignore the relationship among features and the dynamic changes in cardholders' behaviors. We visualize the representations of the general GNN models, including GraphSAGE and GCN. As shown in Figs. 1 and 2, they fail to distance the fraudulent transactions from the legitimate ones. Moreover, GNNs face an over-smoothing problem (indistinguishable representations of nodes in different classes), which results from the over-mixing of information and noise [14, 15, 16]. In the applications of transaction fraud detection, the fact that fraudulent nodes are connected to legitimate ones by disguising the cardholders' behaviors [9], as shown in Fig. 3, exacerbates the effects of the over-smoothing issue.

To tackle the above problem, we propose an Adaptive Sampling and Aggregation-based GNN for transaction fraud detection, named ASA-GNN. It integrates our newly proposed Adaptive Sampling and Aggregation methods. First, we use raw transaction records to construct the transaction graph,
which considers the relationship of features and the dynamic changes in cardholders' behaviors. Based on it, we design a sampler to filter as many noisy neighbors as possible while retaining structural information. Cosine similarity and edge weight are used to select similar neighbor nodes. Then, we over-sample these neighbor nodes to tackle the need for more links among fraudulent nodes. To deal with the camouflage issue of fraudsters, a neighbor diversity metric is defined and calculated based on the entropy among neighbor nodes to distinguish whether neighborhood aggregation is harmful. Each node has its neighborhood aggregation degree. As a result, intraclass compactness and interclass separation can be guaranteed. This work aims to make the following new contributions:

1. We propose a graph neural network that learns discriminative representations to improve the performance of transaction fraud detection.
2. We propose a new sampling strategy to filter noisy nodes and capture neighbors with the same behavior pattern for fraudulent nodes based on the distance between two nodes measured by cosine similarity and edge weight.
3. We define a neighbor diversity metric to make each node adaptive in its aggregation process, which handles the camouflage issue of fraudsters and alleviates the over-smoothing phenomena.
4. Extensive experiments conducted on three financial datasets show that the proposed ASA-GNN achieves significant performance improvements over traditional and state-of-the-art methods.

The rest of this paper is organized as follows. Section II presents the related work. Section III describes the proposed ASA-GNN. Section IV presents three real datasets and discusses the experimental results of performance comparison, ablation studies, and parameter sensitivity analysis. Section V concludes the paper.

## II Background and Related Work

### _Transaction Fraud Detection Model_

Researchers have proposed many methods based on expert rules and machine learning in many fields including transaction fraud detection tasks, which have achieved much success [17, 18, 19, 20]. Their core is to learn some information from historical data to detect fraudulent transactions automatically. They have been proven effective for known fraud patterns but cannot deal with unknown fraud types [21]. Experts have started to use deep learning methods to solve it. Therefore, according to the correlations among the transaction features, deep learning methods can automatically capture cross-feature relationships so that these transaction records can be accurately portrayed, which helps detect fraud behaviors [22]. The Convolutional Neural Network (CNN) method is one of the commonly used methods [22].

In addition to the relationship among transaction features, existing feature engineering methods extract the association of transaction records to improve performance [23]. The aggregation strategy is a classical feature engineering method for transaction fraud detection. It groups the transaction records according to the specified time and then extracts the amount-related features and numbers of these records as the aggregation features [24]. Location and merchant code are also considered and used to generate aggregation features, increasing the user's periodic behavior information [6]. Moreover, some methods, such as a Recurrent Neural Network (RNN) method [25], start to explore the dynamic information of transactions versus time [8, 26]. A Long Short-Term Memory (LSTM) network relies on the evolution of data distribution versus time to capture the dynamic information [26]. By considering the small and various changes in data distribution, an ensemble method is proposed to achieve a better performance [8].

To comprehensively focus on the various mentioned relationships, researchers have utilized transaction records to

Fig. 1: GraphSAGE’s visualization results. The red nodes represent fraudulent transactions, while the others represent legitimate ones. (a) Before training on our financial dataset. (b) After its training on our financial dataset.

Fig. 3: The camouflage issue of fraudsters. Fraudsters attenuate their suspicions by disguising the cardholders’ behaviors such that the detection system thinks they are legitimate transactions.

Fig. 2: GCN’s visualization results.The red nodes represent fraudulent transactions, while the others represent legitimate ones. (a) Before training on our financial dataset. (b) After its training on our financial dataset.
construct a graph [27]. For example, GNN can capture the relationships among transactions and achieve better performance in fraud detection. However, since this method uses only one feature to construct a sparse graph, it fails to mine many useful fraud features [27].

Most of the mentioned approaches fail to comprehensively consider the relationship among transactions, the relationship among the transaction features, and dynamic change information of cardholders' behaviors. In our previous work [28], we constructed a weighted multigraph to tackle the challenge since it can use multiple features as long as logic propositions can represent them. Based on this weighted multigraph, we use GNN to extract the above relationships and the dynamic changes. However, the method has some shortcomings, as stated in Section I. This work is motivated by the need to overcome such shortcomings.

### _Gnn_

A GNN is an effective framework that can learn graph representations by modeling the relationships of non-Euclidean graph data [13]. The concept is initially outlined in [29], where a convolution operation in image processing is used in the graph data processing. After that, several graph-based methods are proposed and applied. Most earlier algorithms obtain the embedding representations in two steps: 1) Obtain a sequence of neighbor nodes for each node by using a random walk strategy; 2) Use machine learning models to gain the topological structure information of a graph and obtain the representation for each node. Although the topological structure information is investigated, these algorithms ignore the attributes of nodes.

Some graph methods utilize the attributes of nodes based on text and statistical information [30, 31, 32]. For example, a Graph Convolutional Network (GCN) method leverages spectral graph convolutions to extract feature information [30]. A Graph Attention Network (GAT) method specifies the contribution of different neighbors by an attention mechanism [31]. GraphSAGE can sample and aggregate neighbor nodes to update the embedding of nodes flexibly [32]. A Relational Graph Convolutional Network (RGCN) method can model relational data [33].

Recent studies have handled large-scale graphs and overcome the problem of computational complexity [34, 35]. Considering that a heterogeneous graph contains a large number of types of nodes and edge information, as well as their changes over time, researchers have proposed heterogeneous GNNs [36], and dynamic GNNs [37]. In addition, the interpretability and structural optimization of GNNs are also studied [38].

However, applying the above GNNs to our transaction fraud detection problem fails to utilize all possible features to construct a graph. The graph built in this way may lack much vital information. A competitive graph neural network (CGNN) method [39] utilizes a heterogeneous graph to model normal and fraudulent behaviors in eCommerce. By a 3D convolutional mechanism, a spatial-temporal attention-based graph network (STAGN) method [40] can detect fraudulent transactions from a location-based transaction graph. MAFI utilizes aggregator-level and relation-level attention to learn neighborhood information and different relation [41]. LGM-GNN uses local and global information to learn more discriminative representations for prediction tasks [42]. Although these methods have tried to learn more discriminative representations, they ignore that excessive aggregation makes indistinguishable representations of nodes in different classes. It results in the over-smoothing phenomenon in GNNs [14]. In the applications of transaction fraud detection, fraudsters often disguise cardholders' behaviors by various means. Thereby, there are some edges among fraud nodes and legitimate ones [9, 43]. It exacerbates the influence of the over-smoothing phenomenon.

Facing the camouflage issue of fraudsters, the CAmouflage-REsistant GNN (CARE-GNN) method [9] defines a label-aware similarity measure using the \(l_{1}\)-distance to select neighbors. However, it only focuses on the similarity of labels. \(l_{1}\)-distance loses its effectiveness in high-dimensional space and fails to describe the similarity among complex behaviors. In our previous work [28], we measure the distance using cosine similarity, which makes up for the shortcoming of \(l_{1}\)-distance. The TG constructed according to transaction data in [28] can focus on the relationship among dynamic transaction behaviors, static transaction attributes, and transactions themselves. However, it ignores that fraudsters avoid trades with others to cover up their behaviors, which results in the lack of links
among fraudulent nodes. Meanwhile, it fails to tackle the issue of over-smoothing. In this work, we utilize cosine similarity and edge weight to remedy the mentioned flaws and focus on estimating whether neighborhood aggregation is harmful to solving the over-smoothing issue.

## III Proposed Approach

This section first describes the preliminaries in the field of transaction fraud detection. After that, ASA-GNN is described in detail. Important notations are listed in Table 1.

### _Preliminary_

**Definition 1**: _Transaction Record. A transaction record \(r\) consists of \(l\) attributes and a label \(y\in\{0,1\}\)._

**Definition 2**: _Transaction Graph (TG). A transaction graph is a weighted multigraph \(\mathcal{G}=(\mathcal{V},\mathcal{R},\mathcal{P},\mathcal{W}eight,\mathcal{E})\), where_

1. \(\mathcal{V}\) is the set of \(|\mathcal{R}|\) nodes and each node \(v\) denotes a record \(r\in\mathcal{R}\);

2. \(\mathcal{P}\) is the set of \(m\) logic propositions that are assertions with respect to the attributes of transaction records and \(m\geq 1\);

3. \(Weight:\mathcal{P}\rightarrow\mathbb{N}\) is a weight function; and

4. \(\mathcal{E}=\bigcup_{i=1}^{m}\{(a,b)_{v}^{p_{i}}|a\in\mathcal{V}\wedge b\in \mathcal{V}\wedge a\neq b\wedge p_{i}(a,b)=True\wedge w=\mathcal{W}eight(p_{i})\}\);

The logic propositions are based on expert rules such that TG ensures the effectiveness of features and reflects the dynamic changes in cardholders' behaviors. In [28], we have defined TG. In comparison with [28], the biggest contributions of this paper lie in the adaptive sampling and aggregation methods, which allow us to utilize GNN to learn the discriminative representations.

Assume that the underlying graph of a GNN is \(\mathcal{G}=\{\mathcal{V},\mathcal{E}\}\). GNNs aim to learn the embedding representations for all nodes and a mapping function such that the predicted results can be obtained. In a general GNN framework [13, 32], the update function for a single layer is as follows:

\[h_{v}^{k}=\sigma(\mathcal{W}^{k}(h_{v}^{k-1}\oplus\mathbb{A}^{k}(\{h_{v^{ \prime}}^{k-1}:v^{\prime}\in\mathcal{N}_{v}\}))), \tag{1}\]

where \(h_{v}^{k}\), \(\sigma\) and \(\mathcal{W}^{k}\) represent the embedding representation of node \(v\), activation function, and shared parameter matrix at \(k\)-th layer respectively. Given a node \(v\), \(\mathcal{N}_{v}\) represents the set of its neighbor nodes, \(\mathbb{A}^{k}\) denotes an aggregator function at the \(k\)-th layer which can aggregate the rich information from \(\mathcal{N}_{v}\) and \(\oplus\) is the operator that combines the embedding of \(v\) and its neighbor nodes.

General aggregator functions include a mean aggregator and a pooling one. The mean aggregator is defined as:

\[\mathbb{A}^{k}=\frac{1}{||\mathcal{N}_{v}||}\sum_{v^{\prime}\in\mathcal{N}_{v }}h_{v^{\prime}}^{k-1}. \tag{2}\]

After the \(K\) layers' learning, we utilize a classification layer to predict the samples' labels:

\[\hat{y_{v}}=Softmax(\mathcal{W}^{K}h_{v}^{K}). \tag{3}\]

In the field of fraud detection, we first construct a TG by transaction records \(\mathcal{R}=\{r_{1},r_{2},...,r_{|\mathcal{R}|}\}\), and then we train the GNN to get the nodes' embedding representations at the last layer and apply a classification layer to predict whether the transaction is fraudulent.

### _Asa-Gnn_

The framework of ASA-GNN is illustrated in Fig. 4. Its main components are neighbor sampling and neighborhood aggregation. In the neighbor sampling stage, to filter noisy neighbors and retain structural information, we define a novel neighbor sampling policy based on cosine similarity and edge weight. In the neighborhood aggregation process, the contributions of different neighbors are specified by an attention mechanism. After that, we apply a diversity metric to ensure the aggregation degree. Finally, a softmax function calculates the probability of a transaction to predict whether it is fraud. All details are described as follows.

#### Iii-B1 Neighbor Sampling Strategy Based on Cosine Similarity and Edge Weight

Simply put, GNNs leverage the information of neighbors to learn more discriminative representations. Existing studies, such as GraphSAGE [32], adopt a random sampling policy under a homophily assumption. However, they ignore the quality of the information from neighbor nodes. Some useless neighbor nodes around a target node result in indistinguishable representations of nodes in different classes. In addition, similar neighbor nodes may provide rich information. Therefore, selecting valid neighbors is necessary before aggregation.

The distance between two nodes and the weight of the edge connecting them are considered to make a novel neighbor sampling policy to deal with this problem. Given a node \(v\in\mathcal{V}\) and its neighbor \(v^{\prime}\in\mathcal{V}\), we utilize cosine similarity to compute their distance, which is usually used to analyze user behaviors in practical applications. We calculate the distance between \(v\) and \(v^{\prime}\), i.e.,

\[\overleftarrow{v},\overleftarrow{v^{\prime}}=exp(r_{v^{\prime}}\cdot r_{v}), \tag{4}\]

where \(r_{v^{\prime}}\) and \(r_{v}^{\prime}\) are the normalized attribute vectors of nodes \(v\) and \(v^{\prime}\). We utilize the exponential function to ensure non-negative similarity.

Note that there may be multiple edges between two nodes in a TG, and the weight of each edge is assigned. The most significant weight of the edge between \(v\) and \(v^{\prime}\) is computed as follows:

\[w_{v,v^{\prime}}=max\{\mu_{i}\cdot Weight(p_{i})\}_{i\in\{1,\cdots,m\}}, \tag{5}\]

where

\[\mu_{i}=\left\{\begin{array}{ll}1&p(v,v^{\prime})=True\\ 0&\text{otherwise.}\end{array}\right. \tag{6}\]

Finally, given a node \(v\in\mathcal{V}\), the probability of its neighbor \(v^{\prime}\) being selected is defined as

\[\mathbb{P}_{v,v^{\prime}}=\frac{w_{v,v^{\prime}}\cdot\overleftarrow{v,v^{\prime }}}{\sum_{v^{\prime}\in\mathcal{N}_{v},v\neq v^{\prime}}w_{v,v^{\prime}} \cdot\overleftarrow{v,v^{\prime}}}, \tag{7}\]

where \(\mathcal{N}_{v}\) denotes the set of neighbor nodes of \(v\). We perform Top-\(\hat{z}\) neighbor sampling to filter noise information from useless neighbor nodes.

After the above neighbor sampling, \(\mathcal{N}_{v}\) contains the selected neighbor nodes of \(v\). However, fraudulent nodes still need neighbors to enrich information. We should find nodes with
the same behavior pattern for them. For this purpose, we over-sample neighbors for fraudulent node \(v\) as follows:

\[\mathcal{N}^{f}_{v}=\{v^{\prime}\in\mathcal{V}|v^{\prime}\not\in\mathcal{N^{ \prime}}_{v}\wedge c^{\prime}_{v}=1\land\overleftrightarrow{v,v^{\prime}}<d_{f }\}, \tag{8}\]

where \(\overleftrightarrow{v,v^{\prime}}\) is the distance between nodes \(v\) and \(v^{\prime}\) calculated by Eq. (4). Therefore,if \(v\) is fraudulent, the set of its neighbors can be defined as follows:

\[\mathcal{N}_{v}=\{\mathcal{N^{\prime}}_{v}\cup\tilde{\mathcal{N}^{f}_{v}}\}. \tag{9}\]

If \(v\) is legitimate, the set of its neighbors \(\mathcal{N}_{v}\) can be updated by \(\mathcal{N^{\prime}}_{v}\).

#### Iii-B2 Attention Mechanism

After the neighbor sampling process, \(\mathcal{N}_{v}\) contains the selected neighbor nodes of \(v\). Then an aggregator function can generate the embedding representations of \(v\) at each layer. Given a node \(v\), \(h^{k}_{v}\) denotes the representation at the \(k\)-th layer where \(v\in\mathcal{V}\) and \(k=1,2,...,K\). Then it aggregates the information from \(\mathcal{N}_{v}\), which is the set of selected neighbor nodes, i.e.,

\[h^{k}_{\mathcal{N}_{v}}=\alpha^{k}_{v,v^{\prime}}\cdot\mathbb{A}^{k}(h^{k-1}_ {v^{\prime}},\forall v^{\prime}\in\mathcal{N}_{v}), \tag{10}\]

\[\alpha^{k}_{v,v^{\prime}}=\frac{exp(LeakyReLU(e^{v^{\prime}}_{v}))}{\sum_{i \in\mathcal{N}_{v}}exp(LeakyReLU(e^{i}_{v}))}, \tag{11}\]

\[e^{v^{\prime}}_{v}=f(\mathcal{W}^{k}h^{k}_{v}||\mathcal{W}^{k}h^{k}_{v^{\prime }}), \tag{12}\]

where \(\alpha^{k}_{v,v^{\prime}}\) denotes the attention score of \(v\) and \(v^{\prime}\) at the \(k\)-th layer, \(\mathbb{A}^{k}\) is an aggregator function at the \(k\)-th layer, \(LeakyReLU\) is an activation function, \(f\) is a function mapping the high-dimensional feature to a real number and \(\mathcal{W}^{k}\) is a shared parameter matrix.

Generally, the interaction between two transaction records within a short interval is more important. Therefore, given a node \(v\) and its neighbor \(v^{\prime}\), the attention score between them

Fig. 4: The overview of ASA-GNN: 1) Neighbor sampling at the node level, in which Top-\(\tilde{z}\) neighbors are sampled filter noise information of each node, and then over-sampling neighbors for fraudulent nodes. 2) Calculating the attention score and aggregation degree to learn representations. 3) Estimating the probability of a transaction being predicted as fraudulent at the detection layer.
at the \(k\)-th layer is adjusted by the normalised time interval \(\{\widetilde{\delta}t_{v,v^{\prime}},\forall v^{\prime}\in\mathcal{N}_{v}\}\), i.e.,

\[\alpha_{v,v^{\prime}}^{k}=\widetilde{\delta}t_{v,v^{\prime}}\cdot\frac{exp(LeakyReLU (e_{v}^{v^{\prime}}))}{\sum_{i\in\mathcal{N}_{v}}exp(LeakyReLU(e_{v}^{i}))}. \tag{13}\]

#### Iii-B3 Adaptive Neighborhood Aggregation

Over-smoothing is a common problem in GNN methods. Existing methods assume that the introduction of noise in the aggregation process causes the problem. Specifically, the information from neighbor nodes in the same class makes the representations maintain compactness within the class, which reflects the advantages of GNN. Interactions between a target node and its neighbors in different classes may result in indistinguishable representations. Although neighbor sampling can help us filter some noisy nodes, the camouflage issue of fraudsters brings another challenge. In applications of transaction fraud detection, fraudsters often disguise the cardholders' behaviors by various means so that there exist edges connecting fraud nodes and legitimate ones in a TG. It exacerbates the effect of the over-smoothing issue. Therefore, when a node has a neighbor in a different class, we should consider that the neighbor may be noisy. We introduce a neighbor diversity metric \(\mathcal{D}\) by computing the entropy among neighbors of a target node, i.e.,

\[\mathcal{D}(v)=-\sum_{c\in C}P_{c}(v)log(P_{c}(v)), \tag{14}\]

\[P_{c}(v)=\frac{|v^{\prime}\in\mathcal{N}_{v}|y_{v^{\prime}}\in c|}{|\mathcal{ N}_{v}|}, \tag{15}\]

where \(C\) represents the set of label classes, including legitimate and fraudulent ones. \(y_{v^{\prime}}\) is the label of \(v^{\prime}\). The greater the value of \(\mathcal{D}(v)\) is, the more diverse the neighbors of \(v\) are.

Considering that each node has a \(\mathcal{D}\), we use a gating function to control the aggregation degree, i.e.,

\[g_{v}^{k}=\sigma(-Norm(\mathcal{D}(v))),\forall v\in\mathcal{V}, \tag{16}\]

where \(Norm\) is the batch normalization for all nodes in a TG. The range of \(g_{v}^{k}\) is (0, 1). When plenty of noisy neighbors are connected to target node \(v\), it is very small and close to 0.

Using the gating function, we allow each node to have its neighborhood aggregation degree. To better understand our adaptive neighborhood aggregation process, the interaction operations of a target node and its neighbors are described, as shown in Fig. 5. The update function for a single layer is as follows:

\[h_{v}^{k}=\sigma(\mathcal{W}^{k}\cdot conccat(h_{v}^{k-1},g_{v}^{k}h_{\mathcal{ N}_{v}}^{k})). \tag{17}\]

#### Iii-B4 Detection Layer

For the target node \(v\), \(h_{v}^{K}\) is the final representation outputted by the \(K\)-th layer. After that, a softmax function can be applied to estimate the probability of a transaction being fraudulent. The loss function is computed as follows:

\[\mathcal{L}=\sum_{i}^{|\mathcal{R}|}-[y_{i}\cdot log(\hat{y_{i}})+(1-y_{i}) \cdot log(1-\hat{y_{i}})], \tag{18}\]

where \(y_{i}\) and \(\hat{y_{i}}\) are the labels of the \(i\)-th transaction record, and the possibility that the sample is predicted to be fraudulent, respectively, and \(|\mathcal{R}|\) represents the number of transactions.

```
Input: TG \(\mathcal{G}=(\mathcal{V},\mathcal{R},\mathcal{P},\mathcal{V}eight,\mathcal{E})\), number of layers \(K\), neighbourhood sample size \(\hat{z}\), edge weight \(\{WWeight_{1},...,Weight_{n}\}\), non-linear activation function \(\sigma\). Output: embedding representation \(h_{v}^{K}\) for each node \(h_{v}^{k}\gets r_{v},\forall v\in\mathcal{V}\); // initialization
1\(h_{v}^{k}\gets r_{v},\forall v\in\mathcal{V}\); // initialization
2forachlayer \(k=1,2,...,K\)do
3forach \(i=1,2,\ldots,\hat{z}_{k}\)do
4// Neighbor sampling
5\(\mathcal{N}_{v}^{i}\leftarrow\) select neighbors from \(\mathcal{N}_{v}\) according to Eq.(7);
6if\(c_{v}=1\)then
7 over-sample neighbors according to Eq.(8);
8
9 end if
10
11 end for
12forachnode \(v\in\mathcal{V}\)do
1//Aggression
13\(\alpha_{v}^{k}\leftarrow\) Eq.(11) ;
14\(h_{N(v)}^{k}\leftarrow\) Eq.(8) ;
15\(g_{v}^{k}\leftarrow\) Eq.(14) ;
16\(h_{v}^{k}\leftarrow\) Eq.(15) ;
17
18 end for
19\(h_{v}^{k}\gets h_{v}^{k}/\left\|h_{v}^{k}\right\|_{2},\forall v\in\mathcal{ V}\);
20
21 end for
```

**Algorithm 1**ASA-GNN Approach

The training process of ASA-GNN is illustrated in Algorithm 1. Given a multigraph \(\mathcal{G}\), we first compute the selection

Fig. 5: The process of adaptive neighborhood aggregation.
probability and then sample \(\hat{z}\) neighbors for each node. Then we can compute attention score \(\alpha_{u,v}^{k}\) and aggregation degree \(g_{v}^{k}\). Finally, the representation for each node at the \(k\)-th layer can be obtained by utilizing an aggregator.

## IV Experiments

Based on three real-world financial datasets, we conduct the following experiments to show the advantages of ASA-GNN.

### _Datasets and Graph Construction_

#### Iv-A1 Datasets

We conduct experiments on one private dataset and two public datasets to demonstrate that ASA-GNN achieves significant improvements over both classic and state-of-the-art models for transaction fraud detection tasks.

The private dataset, PR01, consists of 5.133.5 million transactions from a financial company in Chinahat took place during the second quarter of 2017. Transactions are labeled by professional investigators of a Chinese bank, with 1 representing fraudulent transactions and 0 representing legitimate ones. In data preprocessing, we first utilize the down-sampling of legitimate transactions to solve the imbalanced problem. Then, we apply one-hot coding and min-max normalisation to handle the discrete and continuous values, respectively. Since CARE-GNN requires a lot of computing resources, we take the latest 10000 transaction records as a small dataset (PR02) to facilitate the test.

The TC dataset1 contains 160,764 transaction records collected by Orange Finance Company, including 44,982 fraudulent transactions and 115,782 legitimate transactions. According to the trade time of these transaction records, the training and test sets are divided. Transaction records of one week form the training set and transaction records of the next week form the test set. In this way, the TC dataset is split into TC12, TC23, and TC34. We perform the same data processing as for the PR01 and PR02 datasets.

Footnote 1: [https://challenge.datacasstle.cn/v3/](https://challenge.datacasstle.cn/v3/)

The XF dataset is a subset extracted from iFLYTEK2 which have 20000 records. It contains five types of information, including basic data, media information, time, IP information, and device information. The XF dataset is balanced. Therefore, We only perform the same data processing as the datasets PR01 and PR02 to handle the discrete and continuous values.

Footnote 2: [http://challenge.xfyun.cn/2019/gamedetail?ype=detail/mobileAD](http://challenge.xfyun.cn/2019/gamedetail?ype=detail/mobileAD)

#### Iv-A2 Graph Construction

To construct the TG, the transactions are regarded as nodes. Then, we utilize some logic propositions to design the edges. Generally, fraudsters often have two characteristics: device aggregation and temporal aggregation. Device aggregation means that fraudsters are often limited by financial and regulatory constraints and commit fraud on a small number of devices. It differs from legitimate transactions, where cardholders trade on different devices. Temporal aggregation means that fraudsters must complete the fraud activities as quickly as possible since the banks and cardholders may otherwise discover their activities. Therefore, we construct a TG for the private dataset using two logic propositions as follows:

\[p_{1}(a,b)=\left\{\begin{array}{ll}True&a.Trade\_ip=b.Trade\_ip\ \wedge\\ &|a.Trade\_time-b.Trade\_time|\\ &\leq 0.5h\\ False&\text{otherwise.}\end{array}\right. \tag{19}\]

\[p_{2}(a,b)=\left\{\begin{array}{ll}True&a.Trade\_mac=\\ &b.Trade\_mac\ \wedge\\ &|a.Trade\_time-b.Trade\_time|\\ &\leq 0.5h\\ False&\text{otherwise},\end{array}\right. \tag{20}\]

where \(Trade\_ip\), \(Trade\_time\), and \(Trade\_mac\) are the Internet Protocol address, time and Media Access Control address of the transactions, respectively.

### _Baselines_

To verify the effectiveness of ASA-GNN, the general GNN models and state-of-the-art GNN-based fraud detectors are selected for comparison. The general GNN models includes GCN [32], GraphSAGE [32], GAT [31], RGCN [33] and HAN [44]. The state-of-the-art GNN-based fraud detectors include CARE-GNN [9] and SSA [28].

* **GCN**[30]: The GCN method leverages spectral graph convolutions to extract feature information.
* **GraphSAGE**[32]: GraphSAGE can get a representation for each node using an update function which includes a random sampling policy and neighborhood aggregation process.
* **GAT**[31]: The GAT method uses graph attention layers to specify the importance of different neighbors.
* **CARE-GNN**[9]: It is a GNN method applied to fraud detection, which improves its aggregation with reinforcement learning to identify the behavior of fraudsters.
* **Similar-sample + attention SAGE (SSA)**[28]: The SSA method improves the performance of a model using a sampling strategy and an attention mechanism.
* **RGCN**[33]: RGCN models a relational GNN for link prediction tasks and classification tasks.
* **HAN**[44]: HAN utilizes a hierarchical attention mechanism so that the contributions of different neighbors and meta-paths can be learned.

### _Parameter Settings_

In ASA-GNN, we set \(K=3\) as the number of layers, \((20,20,20)\) as the neighborhood sample size, \(32\) as the hidden
size, \(0.001\) as the learning rate, \(Adam\) as the optimizer and \(256\) as the batch size for our PR01 and PR02 datasets. We set \(K=3\) as the number of layers, \((30,50,50)\) as the neighborhood sample size, \(16\) as the hidden size, \(0.01\) as the learning rate, \(Adam\) as the optimizer and \(128\) as the batch size for the XF, TC12, TC23, and TC34 datasets. For all baseline algorithms, their parameters are the same as those in the corresponding papers [28, 30, 31, 32, 33, 9, 34].

### _Evaluation Criteria_

To measure the performance, we choose \(Recall\), \(F_{1}\), and Area Under the Curve of ROC (\(AUC\)) as criteria. \(Recall\) represents the ratio of the identified fraudulent transaction records to all fraudulent ones. \(F_{1}\) is a common evaluation criteria in binary classification problems [42]. \(AUC\) is usually computed to evaluate a model on an imbalanced dataset. \(Recall\) and \(F_{1}\) are calculated as follows:

\[Recall=\frac{T_{P}}{T_{P}+T_{N}}, \tag{21}\]

\[Precision=\frac{T_{P}}{T_{P}+F_{P}}, \tag{22}\]

\[F_{1}=\frac{2\times Recall\times Precision}{Recall+Precision}, \tag{23}\]

where \(T_{P}\), \(T_{N}\), and \(F_{P}\) are the numbers of true positive transaction records, true negative transaction records, and false positive transaction records, respectively.

\(AUC\) is calculated as follows:

\[AUC=\frac{\sum_{r\in\mathcal{R}^{+}}rank_{r}-\frac{|\mathcal{R}^{+}|\times(| \mathcal{R}^{+}|+1)}{2}}{|\mathcal{R}^{+}|\times|\mathcal{R}^{-}|}, \tag{24}\]

where \(\mathcal{R}^{+}\) and \(\mathcal{R}^{-}\) are the fraudulent and legitimate class sets and \(rank_{r}\) is the rank of \(r\) by the predicted score.

### _Performance Comparison_

The performance of ASA-GNN and all baselines are presented in Table. 3. The ROC curves of ASA-GNN and all baselines are shown in Fig. 8. We have the following observations and analysis results:

* The proposed ASA-GNN achieves significant improvements over all baselines on the PR01, PR02, XF, TC12, and TC34 datasets. ASA-GNN improves significantly by 6.8% and 6.7% in terms of \(F_{1}\) and \(AUC\) on the TC12 dataset. Therefore, the overall performance demonstrates the superiority of the proposed ASA-GNN.
* GCN, GraphSAGE, GAT, RGCN, and HAN are traditional GNNs, neither of which can identify the camouflage behavior of fraudsters. Thus, their performance is worse than ASA-GNN.
* GraphSAGE, CARE-GNN, and SSA are all graph algorithms based on node sampling. None of them performs better than ASA-GNN. The reason is that the proposed ASA-GNN filters nodes effectively and supplements the information of minority nodes, i.e., fraud information. In addition, ASA-GNN considers the camouflage behaviors of fraudsters. The performance of GraphSAGE is worse than that of SSA because noise information may be absorbed in the former's sampling process, and the importance of different nodes needs to be considered.
* CARE-GNN calculate the \(l_{1}\)-distance between nodes. However, it only focuses on the similarity of labels and the \(l_{1}\)-distance loses its effectiveness in high-dimensional space. Although it tries its best to solve the camouflage issue of fraudsters, it still performs poorly.

## V Conclusion and Future Work

In this paper, a novel graph neural network named ASA-GNN is proposed to identify fraudulent transactions. ASA
GNN employs the neighbor sampling strategy to filter noisy nodes and make up for the lack of neighbors of fraudulent nodes. Consequently, it can make full use of attribute and topology information in TGs. Besides, ASA-GNN can address the camouflage issue of fraudsters and alleviate the over-smoothing phenomena, benefiting from our neighbor diversity metric. Extensive experiments on three financial datasets show that the proposed ASA-GNN achieves significant performance improvements over traditional and state-of-the-art methods. Therefore, ASA-GNN can better help banks and financial institutions detect fraudulent transactions and establish trust relationships with customers.

Our plan includes designing an explainer for the detection model produced by ASA-GNN since the lack of explanations may make customers distrust financial institutions [45]. Our TG is built based on expert rules, which can provide a feasible way to develop such an explainer. Studying the imbalance issues in transaction graphs and adding temporal modules (TCN/Transformer) to improve the ability to capture temporal features is also interesting.
