liveBook · Manning

Graph convolution

As explained in Financial AI in Practice

A neural-network layer that transforms node features and combines information from neighboring nodes in a graph.

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

How Financial AI in Practice covers it

How deep it goes
Explains linear transformation, adjacency-based aggregation, and feature combination, while deferring specialized layers for large, dynamic graphs.
Examples
Demonstrates transaction features based on amount and time, with graph edges for shared users or devices.
What you can do after
Build from scratch a simplified two-layer graph neural network for transaction fraud classification.
How it connects
Connects graph convolution to message passing, adjacency matrices, node features, and graph neural networks.

Also explained in

Compare how 2 books explain graph convolution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Financial AI in Practice. The section links point to the parts of the book it draws on.