Back to the projects

University

Bachelor thesis: graph neural networks for customer profiling

Which product category will a customer buy next? In my bachelor thesis I looked at customers and products as a graph that grows with every purchase – and trained a temporal graph neural network that predicts new connections in this graph.

  • Python
  • PyTorch Geometric
  • Temporal GNN
  • Graph attention

Approach following CRISP-DM

  1. Business understanding: make marketing more targeted – fitting offers instead of mass advertising
  2. Data understanding: review the available data, clarify legal and ethical conditions
  3. Data preparation: two years of purchase data, incomplete rows removed, rare categories dropped, new feature “customer loyalty level”, time as Unix timestamps
  4. Modeling: temporal graph network with expander graph rewiring, trained in Google Colab
  5. Evaluation: ranking of the predicted categories, scored with the mean reciprocal rank

Why a temporal graph?

  • Every purchase is an edge between a customer and a product category – with a timestamp
  • A temporal graph network (TGN) keeps a state (“memory”) for every node and updates it with every new event
  • Training runs in batches in time order – the model never sees the future

Rewiring with expander graphs (TGR)

  • Typical problems: distant nodes do not exchange information (under-reaching), information piles up on a few edges (over-squashing), rarely active nodes go stale (memory staleness)
  • Solution after Petrović et al. (2024): an additional, artificial expander graph with well-spread shortcuts
  • Both views – real and artificial graph – are combined, so all nodes stay up to date

Result and outlook

  • Mean reciprocal rank: how high does the right category land? The model was very accurate after only a few epochs – without any hyperparameter tuning
  • A prototype: using it in production would need infrastructure, scaling and monitoring
  • Further ideas: more customer features, longer periods, transfer to cross-selling and new customers

Tech

  • Python, pandas, PyTorch, PyTorch Geometric (TemporalData)
  • Temporal graph network, graph attention, link prediction
  • Google Colab (GPU)