Graph convolution transforms node features and combines them with information from neighboring nodes. In fraud detection, this lets a model learn from relationships among financial entities rather than relying only on manually engineered relational features. section 9.4 section 9.4.2
A simplified layer follows three steps:
- Apply a linear transformation to node features. section 9.4.2
- Multiply the transformed features by the adjacency matrix to aggregate neighbor information. section 9.4.2
- Add the aggregated information to each node’s transformed features, combining local context with its own representation. section 9.4.2
Transaction fraud detection
Represent transactions with amount and time features, and connect transactions that share a user or device. A two-layer model applies graph convolution before classifying transactions as normal or fraudulent. section 9.4.2 section 9.4.2
Listing 9.7 Defining the GNN model
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
from scipy.sparse import csr_matrix
# Simple GNN Model
class FraudGNN(nn.Module):
def __init__(self, input_dim, hidden_dim=32):
super(FraudGNN, self).__init__()
self.conv1 = nn.Linear(input_dim, hidden_dim)
self.conv2 = nn.Linear(hidden_dim, hidden_dim)
self.classifier = nn.Linear(hidden_dim, 2) # Normal/Fraud
def forward(self, x, adj):
# First GNN layer: Aggregate neighbor information
h1 = torch.relu(self.conv1(x))
h1_agg = torch.mm(adj, h1) # Average neighbors' information
h1 = h1 + h1_agg
# Second GNN layer
h2 = torch.relu(self.conv2(h1))
h2_agg = torch.mm(adj, h2)
h2 = h2 + h2_agg
# Classification
out = self.classifier(h2)
return out
Inspect a simplified PyTorch model showing linear transformations, adjacency-based aggregation, and a two-class classifier. section 9.4.2
This construction illustrates message passing, but real fraud-detection GNNs may use specialized layers and more sophisticated methods to handle large, dynamic financial graphs. section 9.4 section 9.4.2

