SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Considering the large difference in the range  $[d_{mean}, d_{i,max}]$  for each node and the randomness in truncation, NSGT performs a sequentially iterative truncation rather than a single-pass truncation. In each iteration it randomly removes some non-homophily edges with probability proportional to the distance between their associated nodes, and then it updates the range  $[d_{mean}, d_{i,max}]$  for nodes that have edges being removed. Thus, for  $K$  iterations on a graph  $G$ , it would produce a set of  $K$  sequentially truncated graphs with the corresponding truncated adjacency matrices  $\mathcal{A} = \{\tilde{\mathbf{A}}_1, \tilde{\mathbf{A}}_2, \dots, \tilde{\mathbf{A}}_K\}$ . Note that since the graph is sequentially truncated, we have  $\mathcal{E}_{i+1} \subset \mathcal{E}_i$ , where  $\mathcal{E}_i$  is the edge set left after the i-th iteration. As shown in Fig. 3(c-d), such a sequentially iterative truncation helps largely increase the homophily of the normal nodes, while at the same time effectively removing non-homophily edges gradually.
Training. To detect anomalies in different graph truncation scales, we train a LAMNet on each of the  $K$  sequentially truncated adjacency matrices in
$\mathcal{A}$ , resulting in  $K$  LAMNets parameterized by  $\{\Theta_1, \Theta_2, \dots, \Theta_K\}$  for various truncation depths. Particularly, for each LAMNet, instead of using  $\mathbf{A}$ , its graph convolutions across all GCN layers are performed on the truncated adjacency matrix  $\tilde{\mathbf{A}}_k$  as follows to mitigate the biases caused by the
Figure 3: (a) and (b) are respectively the Euclidean distance statistics of the homophily (N-N) edges that connect normal nodes and the non-homophily (N-A) edges that connect normal and abnormal nodes on BlogCatalog and Amazon. (c) Homophily of normal nodes vs. (d) the number of non-homophily edges with increasing truncation iterations/departs.
non-homophily edges in message passing:
$$
\mathbf {H} ^ {(\ell)} = \phi \left(\mathbf {D} ^ {- \frac {1}{2}} \tilde {\mathbf {A}} _ {k} \mathbf {D} ^ {- \frac {1}{2}} \mathbf {H} ^ {(\ell - 1)} \mathbf {W} ^ {(\ell - 1)}\right). \tag {9}
$$
In doing so, we complete the training of a TAM-based base model, consisting of  $K$  LAMNets.
Further, being a probabilistic approach, NSGT has some randomnesses in the graph truncation, and so does the LAMNets. To make use of those randomness, we build an ensemble of TAM models with a size of  $T$ , as shown in Fig. 2(a). That is, for a graph  $G$ , we perform NSGT  $T$  times independently, resulting in  $T$  sets of the truncated adjacency matrix set  $\{\mathcal{A}_1, \mathcal{A}_2, \dots, \mathcal{A}_T\}$ , with each  $\mathcal{A} = \{\tilde{\mathbf{A}}_1, \tilde{\mathbf{A}}_2, \dots, \tilde{\mathbf{A}}_K\}$ . We then train a LAMNet on each of these  $T \times K$  adjacency matrices, obtaining an ensemble of  $T$  TAM models (i.e.,  $T \times K$  LAMNets).
Note that in training the LAMNets, the local affinity in the first term in Eq. (5) is computed using the original adjacency matrix  $\mathbf{A}$ . This is because we aim to utilize the primary graph structure for local affinity-based GAD; the graph truncation is designed to mitigate the graph convolution biases only.
Inference. During inference, we can obtain one local node affinity-based anomaly score per node from each LAMNet, and we aggregate the local affinity scores from all  $T \times K$  LAMNets to compute an overall anomaly score as
$$
\operatorname {s c o r e} \left(v _ {i}\right) = \frac {1}{T \times K} \sum_ {t = 1} ^ {T} \sum_ {k = 1} ^ {K} f _ {T A M} \left(v _ {i}; \Theta_ {t, k} ^ {*}, \mathbf {A}, \mathbf {X}\right), \tag {10}
$$
where  $\Theta_{t,k}^{*}$  is the learned weight parameters for the LAMNet using the  $k$ -th truncated adjacency matrix in the  $t$ -th TAM model. The weaker the local node affinity in the learned representation spaces under various graph truncation scales, the larger the anomaly score the node  $v_{i}$  has.
Datasets. We conduct the experiments on six commonly-used publicly-available real-world GAD datasets from diverse online shopping services and social networks, and citation networks, including BlogCatalog [49], ACM [48], Amazon [10], Facebook [56], Reddit, and YelpChi [21]. The first two datasets contain two types of injected anomalies – contextual and structural anomalies [8, 34] – that are nodes with significantly deviated graph structure and node attributes respectively. The other four datasets contain real anomalies. Detailed information about the datasets can be found in App. B.
Competing Methods and Performance Metrics. TAM is compared with two state-of-the-art (SOTA) shallow methods – iForest [25] and ANOMALOUS [41] – and five SOTA GNN-based deep methods, including three self-supervised learning based methods – CoLA [28], SL-GAD [63], and HCM-A [17] – and two reconstruction-based methods – DOMINANT [8] and ComGA [31]. iForest works on the raw node attributes, while ANOMALOUS works on the raw node attributes and graph structure. The other methods learn new representation space for GAD.
Following [4, 38, 52, 64], two popular and complementary evaluation metrics for anomaly detection, Area Under the Receiver Operating Characteristic Curve (AUROC) and Area Under the precision-recall curve (AUPRC), are used. Higher AUROC/AUPRC indicates better performance. The reported AUROC and AUPRC results are averaged over 5 runs with different random seeds.
Implementation Details. TAM is implemented in Pytorch 1.6.0 with python 3.7 and all the experiments are run on an NVIDIA GeForce RTX 3090 24GB GPU. In TAM, each LAMNet is implemented by a two-layer GCN, and its weight parameters are optimized using Adam [19] optimizer with 500 epochs and a learning rate of  $1e - 5$  by default.  $T = 3$  and  $K = 4$  are used for all datasets. Datasets with injected anomalies, such as BlogCatalog and ACM, require strong regularization, so  $\lambda = 1$  is used by default; whereas  $\lambda = 0$  is used for the four real-world datasets. Hyperparameter analysis w.r.t.  $K$  is presented in Sec. 4.2. TAM can perform stably within a range of  $T$  and  $\lambda$  (see App. C.1 for detail). All the competing methods are based on their publicly-available official source code, and they are trained using their recommended optimization and hyperparameter settings in the original papers.
Table 1: AUROC and AUPRC results on six real-world GAD datasets with injected/real anomalies. The best performance per row is boldfaced, with the second-best underlined.
Metric	Method	Dataset
BlogCatalog	ACM	Amazon	Facebook	Reddit	YelpChi
AUROC	iForest	0.3765±0.019	0.5118±0.018	0.5621±0.008	0.5382±0.015	0.4363±0.020	0.4120±0.040
ANOMALOUS	0.5652±0.025	0.6856±0.063	0.4457±0.003	0.9021±0.005	0.5387±0.012	0.4956±0.003
DOMINANT	0.7590±0.010	0.8569±0.020	0.5996±0.004	0.5677±0.002	0.5555±0.011	0.4133±0.010
CoLA	0.7746±0.009	0.8233±0.001	0.5898±0.008	0.8434±0.011	0.6028±0.007	0.4636±0.001
SL-GAD	0.8123±0.002	0.8479±0.005	0.5937±0.011	0.7936±0.005	0.5677±0.005	0.3312±0.035
HCM-A	0.7980±0.004	0.8060±0.004	0.3956±0.014	0.7387±0.032	0.4593±0.011	0.4593±0.005
ComGA	0.7683±0.004	0.8221±0.025	0.5895±0.008	0.6055±0.000	0.5453±0.003	0.4391±0.000
TAM (Ours)	0.8248±0.003	0.8878±0.024	0.7064±0.010	0.9144±0.008	0.6023±0.004	0.5643±0.007
AUPRC	iForest	0.0423±0.002	0.0372±0.001	0.1371±0.002	0.0316±0.003	0.0269±0.001	0.0409±0.000
ANOMALOUS	0.0652±0.005	0.0635±0.006	0.0558±0.001	0.1898±0.004	0.0375±0.004	0.0519±0.002
DOMINANT	0.3102±0.011	0.4402±0.036	0.1424±0.002	0.0314±0.041	0.0356±0.002	0.0395±0.020
CoLA	0.3270±0.000	0.3235±0.017	0.0677±0.001	0.2106±0.017	0.0449±0.002	0.0448±0.002
SL-GAD	0.3882±0.007	0.3784±0.011	0.0634±0.005	0.1316±0.020	0.0406±0.004	0.0350±0.000
HCM-A	0.3139±0.001	0.3413±0.004	0.0527±0.015	0.0713±0.004	0.0287±0.005	0.0287±0.012
ComGA	0.3293±0.028	0.2873±0.012	0.1153±0.005	0.0354±0.001	0.0374±0.001	0.0423±0.000
TAM (Ours)	0.4182±0.005	0.5124±0.018	0.2634±0.008	0.2233±0.016	0.0446±0.001	0.0778±0.009
Effectiveness on Diverse Real-world Datasets. The AUROC and AUPRC results on six real-world GAD datasets are reported in Tab. 1. TAM substantially outperforms all seven competing methods on all datasets except Reddit in both metrics, having maximally  $9\%$  AUROC and  $12\%$  AUPRC improvement over the best-competing methods on the challenge dataset Amazon; on Reddit, it ranks second and performs similarly well to the best contender CoLA. Further, existing methods perform very unstably across different datasets. For example, DOMINANT performs well on ACM but badly on the other datasets; CoLA works well on Reddit but it fails in the other datasets. Similar observations are found in a recent comprehensive comparative study [26]. By contrast, TAM can perform consistently well on these diverse datasets. This is mainly because i) the proposed one-class homophily is more pervasive than the GAD intuitions used by existing methods in different datasets, and ii) TAM offers an effective anomaly scoring function to utilize this anomaly-discriminative property for accurate GAD.
On Detecting Structural and Contextual Anoma
lies. We further examine the effectiveness of TAM on detecting two commonly-studied anomaly types, structural and contextual anomalies, with the results on BlogCatalog and ACM reported in Tab. 2, where the three best competing methods on the two datasets in Tab. 1 are used as baselines. Compared to contextual anomalies, it is significantly more challenging to detect structural anomalies, for which TAM outperforms all three methods in both AUROC and AUPRC. As for contextual anomalies, although TAM underperforms SL-GAD and ranks in second AUPRC than SL-GAD. Note that compared to AUROC and indicates overoptimistic performance, AUPRC is performance on the anomaly class exclusively [3,38]. So of the two datasets demonstrates the superiority of TAM anomaly. These results also indicate that structural and contextual anomalies, but both of which often have we:
Table 2: AUROC and AUPRC results of detecting structural and contextual anomalies.
Metric	Method	Dataset
BlogCatalog	ACM
Structural	Contextual	Structural	Contextual
AUROC	DOMINANT	0.5769	0.9591	0.6533	0.9506
CoLA	0.6524	0.8867	0.7468	0.9200
SL-GAD	0.5853	0.9754	0.7354	0.9878
TAM	0.6819	0.9627	0.7902	0.9534
AUPRC	DOMINANT	0.0567	0.4369	0.0452	0.5049
CoLA	0.0370	0.6298	0.0381	0.6166
SL-GAD	0.0359	0.4776	0.0314	0.3083
TAM	0.0570	0.6308	0.0568	0.7126
TAM vs. Raw/Generic Node Representation
Space. As discussed in Sec. 1, local node affinity requires a new node representation space that is learned for the affinity without being biased by non-homophily edges. We provide quantitative supporting results in Tab. 3, where TAM is compared with Raw Attribute (RA), and the spaces learned by DGI [51] and GMI [40]. It is clear that the representations learned by TAM significantly outperforms all three competing representation spaces on all six datasets.
Table 3: Using local node affinity on raw attributes (RA) and learned representation spaces. OOM denotes out of memory on a 24GB GPU.
Metric	Method	Dataset
BlogCatalog	ACM	Amazon	Facebook	Reddit	YelpChi
AUROC	RA	0.5324	0.7520	0.6722	0.4176	0.5794	0.3331
DGI	0.5647	0.7823	0.4979	0.8647	0.5489	0.5254
GMI	0.5880	0.7985	0.4438	0.8594	0.4503	OOM
TAM (Ours)	0.8238	0.8878	0.7064	0.9065	0.5923	0.5541
AUPRC	RA	0.0652	0.1399	0.1237	0.0193	0.0526	0.0348
DGI	0.0662	0.1991	0.0719	0.1260	0.0398	0.0551
GMI	0.0748	0.2251	0.0578	0.1108	0.0281	OOM
TAM (Ours)	0.4178	0.5124	0.2541	0.2362	0.0446	0.0778
Computational Efficiency. The runtime (including both training and inference time) results are shown in Tab. 4. DOMINANT and ComGA are the simplest GNN-based methods, achieving the most efficient methods. Our method needs to perform multiple graph truncation and train multiple LAMNets, so it takes more time than these two reconstruction-based methods, but it runs much faster than the three recent SOTA models,
HCM-A, CoLA, and SL-GAD, on most of the datasets. A detailed analysis is provided in App. C.2.
Table 4: Runtime (in seconds) results.
Method	Dataset
BlogCatalog	ACM	Amazon Facebook	Reddit	YelpChi
DOMINANT	30	48	9	7	10	26
ComGA	320	542	115	67	159	425
HCM-A	2,664	36,254	1,111	12.7	1,228	71,891
CoLA	715	2,982	2,180	84	3,800	18,194
SL-GAD	3,055	5,728	3,071	314	4,156	19,588
TAM (Ours)	214	827	362	41	391	837
Graph Truncation NSGT. Three alternative approaches to our graph truncation NSGT include:
i) Raw Graph (RG) that directly performs affinity maximization on the original graph structure without any graph truncation, and ii) Edge Drop (ED) that randomly drops some edges (5% edges by default) [7]. iii) Similarity Cut (SC) (removing 5% least similar edges). We compare NSGT to these three approaches in the TAM framework in Tab. 5. It is clear that NSGT consistently and significantly outperforms both
Table 5: NSGT vs. RG and ED.
Metric	Method	Dataset
BlogCatalog	ACM	Amazon	Facebook	Reddit	YelpChi
AUROC	RG	0.6728	0.7511	0.4763	0.8186	0.5575	0.4943
ED	0.5678	0.7162	0.4574	0.8641	0.5641	0.5014
SC	0.6650	0.8668	0.5856	0.6951	0.6007	0.4910
NSGT	0.8235	0.8830	0.7120	0.9105	0.5938	0.5449
AUPRC	RG	0.1849	0.1145	0.0619	0.0808	0.0385	0.0530
ED	0.1229	0.1876	0.0669	0.1204	0.0417	0.0519
SC	0.1621	0.5109	0.0924	0.0410	0.0467	0.0598
NSGT	0.4150	0.5152	0.2555	0.2200	0.0449	0.0775
alternative approaches. RawGraph does not work well due to the optimization biases caused nonhomophily edges. EdgeDrop is ineffective, which is even less effective than RawGraph, as it often removes homophily edges rather than the opposite due to the overwhelming presence of such edges in a graph. SimilarityCut also significantly underperforms our NSGT on nearly all cases. This is mainly because this variant would fail to take account of local affinity distribution of each node as being captured in NSGT. As a result, it could remove not only non-homophily edges but also homophily edges associated with normal nodes whose local affinity is not as strong as the other normal nodes, which would be the opposite to the objective of the optimization in TAM, leading to less effective detection performance.
Affinity Maximization Network LAMNet. The importance of LAMNet is examined by comparing it to its two variants, including Raw Truncated Affinity (RTA) that directly calculates the local affinity-based anomaly scores after NSGT (i.e., without involving LAMNet at all), and DOM that performs LAMNet but with our affinity maximization objective replaced
Table 6: LAMNet vs. RTA and DOM.
Metric	Method	Dataset
BlogCatalog	ACM	Amazon	Facebook	Reddit	YelpChi
AUROC	RTA	0.7497	0.8043	0.6256	0.8161	0.5783	0.5118
DOM	0.7642	0.8679	0.5169	0.7793	0.5863	0.5154
LAMNet	0.8248	0.8878	0.7064	0.9144	0.5923	0.5643
AUPRC	RTA	0.3329	0.2698	0.1195	0.1212	0.0437	0.0615
DOM	0.3115	0.4525	0.1517	0.1506	0.0466	0.0538
LAMNet	0.4182	0.5124	0.2630	0.2233	0.0450	0.0766
by the popular graph reconstruction loss used in DOMINANT [8]. As shown by the comparison results reported in Tab. 6, LAMNet consistently and significantly outperforms both RTA and DOM, showing that LAMNet can make much better use of the truncated graphs. In addition, by working on our truncated graphs,  $DOM$  can substantially outperform its original version DOMINANT in Tab. 1 on most of the datasets. This indicates that the proposed one-class homophily property may be also exploited to improve existing GAD methods.
Anomaly Scoring. We compare the TAM anomaly scoring to its two variants: i) TAM-T that calculates the node affinity in Eq. (5) on the truncated graph structure rather than the primary graph structure as in TAM, and ii) Degree that directly uses the node degree after our graph truncation as anomaly score. As illustrated by the AUPRC results in Fig. 4(a), TAM consistently and significantly outperforms both variants. Degree obtains fairly good performance, which shows that our graph truncation results in structural changes that are
Figure 4: (a) TAM vs. Degree and TAM-T. (b) TAM results w.r.t. graph truncation depth  $K$ .
beneficial to GAD. TAM-T underperforms TAM since the local affinity based on the truncated graph structure is affected by randomness and uncertainty in the truncation, leading to unstable and suboptimal optimization. We also show in Fig. 4 (b) that aggregating the anomaly scores obtained from different truncation scales/de depths helps largely improve the detection performance. Similar observations are found in the corresponding AUROC results (see App. C.3).
4.3 Performance on Large-scale Graphs
In order to demonstrate the effectiveness of TAM on the large-scale datasets, we conduct the experiments on the four large-scale datasets with a large set of nodes and edges, Amazon-all and YelpChi-all by treating the different relations as a single relation following [6], T-Finance [47] and OGB-Proteins [14]. The experimental results are shown in Tab. 7. Due to the increased number of nodes and edges, we set  $K = 7$  for these datasets. TAM can perform consistently well on
these large-scale datasets and outperforms four comparing methods, which provides further evidence about the effectiveness of our proposed one-class homophily and anomaly measure.
Table 7: Results on large-scale graphs
Metric	Method	Dataset
Amazon-all	YelpChi-all	T-Finance	OGB-Proteins
AUROC	DOMINANT	0.6937	0.5390	0.5380	0.7267
ComGA	0.7154	0.5352	0.5542	0.7134
CoLA	0.2614	0.4801	0.4829	0.7142
SL-GAD	0.2728	0.5551	0.4648	0.7371
TAM	0.8476	0.5818	0.6175	0.7449
AUPRC	DOMINANT	0.1015	0.1638	0.0474	0.2217
ComGA	0.1854	0.1658	0.0481	0.1554
CoLA	0.0516	0.1361	0.0410	0.1349
SL-GAD	0.0444	0.1711	0.0386	0.1771
TAM	0.4346	0.1886	0.0547	0.2173
4.4 Handling Camouflage Attributes
Fraudsters may adjust their behaviors to camouflage their malicious activities, which could hamper the performance of GNN-based methods. We evaluate the performance of TAM when there are camouflages in the raw attributes. Particularly, we replace  $10\%$ ,  $20\%$ ,  $30\%$  randomly sampled original attributes with camouflaged attributes, in which the feature/attribute value of the abnormal nodes is replaced (camouflaged) with the mean feature value of the normal nodes. The results are shown in the Tab. 8, which demonstrates that TAM is robust to a high level of camouflaged features and maintains its superiority over the SOTA models that work
on the original features. The reason is that NSGT can still successfully remove some non-homophily edges in the local domain, allowing LAMNet to make full use of the one-class homophily and achieve good performance under the camouflage.
Table 8: Results under different levels of camouflage attributes
Metric	Method	Dataset
0%	10%	20%	30%
AUROC	BlogCatalog	0.8218	0.8045	0.8022	0.7831
ACM	0.8878	0.8727	0.8688	0.8652
Amazon	0.7064	0.7036	0.6954	0.6838
Facebook	0.9144	0.8870	0.8804	0.8650
Reddit	0.6023	0.5998	0.5915	0.5876
YelpChi	0.5640	0.5447	0.5271	0.5301
AUPRC	BlogCatalog	0.4182	0.4014	0.4024	0.4095
ACM	0.5124	0.4896	0.4614	0.4822
Amazon	0.2634	0.2502	0.2400	0.2324
Facebook	0.2233	0.2225	0.2126	0.2015
Reddit	0.0446	0.0444	0.0414	0.0440
YelpChi	0.0778	0.0726	0.0701	0.0678
This paper reveals an important anomaly-discriminative property, the one-class homophily, in GAD datasets with either injected or real anomalies. We utilize this property to introduce a novel unsupervised GAD measure, local node affinity, and further introduce a truncated affinity maximization (TAM) approach that end-to-end optimizes the proposed anomaly measure on truncated adjacency matrix. Extensive experiments on 10 real-world GAD datasets show the superiority of TAM over seven SOTA detectors. We also show that the one-class homophily can be exploited to enhance the existing GAD methods.
Limitation and Future Work. TAM cannot directly handle primarily isolated nodes in a graph, though those isolated nodes are clearly abnormal. Additionally, like many GNN-based approaches, including GAD methods, TAM also requires a large memory to perform on graphs with a very large node/edge set. The one-class homophily may not hold for some datasets, such as datasets with strong heterophily relations/subgraphs of normal nodes [1, 29, 36, 46, 62, 66]. Our method would require some adaptations to work well on the dataset with strong heterophily or very large graphs, which are also left for future work.
Acknowledgments. We thank the anonymous reviewers for their valuable comments. The work is supported in part by the Singapore Ministry of Education Academic Research Fund Tier 1 grant (21SISSMU031).
A One-Class Homophily Phenomenon
Fig. 5 shows the one-class homophily phenomenon on the rest of four datasets, in which ACM is a dataset with injected anomalies while the other three datasets contain real anomalies. The results here are consistent with that in the main text.
Given the graph along with the ground truth labels, following [13, 33], the homophily and heterophily are defined as the ratio of the edges connecting the node with the same classes and different classes, respectively:
$$
\left\{ \begin{array}{l} X _ {\text {h e t e r o}} (v) = \frac {1}{| \mathcal {N} (v) |} \left| \left\{u: u \in \mathcal {N} (v), y _ {u} \neq y _ {v} \right\} \right| \\ X _ {\text {h o m o}} (v) = \frac {1}{| \mathcal {N} (v) |} \left| \left\{u: u \in \mathcal {N} (v), y _ {u} = y _ {v} \right\} \right| \end{array} \right. \tag {11}
$$
where  $y_{v}$  is the label to denote whether the node  $v$  is an anomaly or not. Note that one-class homophily may not always hold, or it is weak in some datasets. YelpChi which connects the reviews posted by the same user, e.g., YelpCh-RUR is an example of the latter case. As shown in Figure 5, the homophily distribution of normal and abnormal nodes is similar in YelpCh-RUR, whose pattern is different from the large distribution gap in the other three datasets. Since the normal nodes' homophily is generally stronger than the abnormal nodes, we can still successfully remove the non-homophily edges that connect normal and abnormal nodes with a higher probability than the homophily edges, resulting in a truncated graph with stronger one-class homophily.
We conduct the experiments on two real-world dataset with injected anomalies and four real-world with genuine anomalies in diverse online shopping services, social networks, and citation networks, including BlogCatalog [49], ACM [48], Amazon [10], Facebook [56], Reddit, YelpChi [21], as well as four large-scale graph datasets. The statistical information including the number of nodes, edge, the dimension of the feature, and the anomalies rate of the datasets can be found in Tab. 9.