How we built a library for graph neural networks at MTS

Diana Pavlikova22 Oct 2024

Problem

An ML team at MTS works on credit scoring: predicting client default on bank loans (a 90-day delinquency within 12 months). Gradient boosting handles this well, yet business users keep asking for better quality. Boosting treats each client as an independent row, so it ignores the links between clients, such as money transfers. Writing a graph neural network (GNN) from scratch is slow and expensive, so GNNs are rarely used.

Example from the article: a scoring task with four targets (default on a consumer loan, a credit card and two other products), two types of nodes with 150 features each, 26 edge features, and 15–20 million nodes per month.

Solution in brief

Treat the scored objects as nodes of a heterogeneous graph, sample a fixed number of neighbors per node, and train one multi-target GNN with edge-aware NNConv layers. The team put preprocessing, batching, neighbor sampling and Optuna tuning into the open-source CoolGraph library, so a first model takes two lines of code.

Questions this case answers
  • How to add relational information between entities to a tabular prediction model when boosting on independent per-entity features has plateaued
  • How to train one model for several related binary targets on a graph where most nodes are unlabeled and nodes come in two types with different features
  • How to improve a credit default model when a gradient boosting model on per-client features has stopped improving?
  • How to train a graph neural network on a heterogeneous client graph with node features, edge features and several targets?

Tools and methods

  • CoolGraph — open-source (MIT) library on top of PyTorch Geometric: sampling, batching, tuning, NNConv and GraphConv.
  • NNConv — graph convolution whose weights depend on edge features.
  • GraphConv — graph convolution with fixed edge weights, used when edges carry no features.
  • NeighborLoader — samples neighbors for each target node and cuts the graph into batches.
  • Optuna — tunes training and architecture parameters.
  • MLflow — tracks the metric during training.
Continue reading — it's free

Google or a one-time email code. No password.