Suffering ML: how we automated data checks for models

Denis Zankov24 Jan 2023

Problem

The retail ML team at Gazprombank trains boosted trees and neural networks on very large data marts: thousands of variables per time slice, aggregated over millions of customers. A failed join, a change at the source or new business logic can silently break the models downstream. ETL-level checks, manual inspection of distributions, binning and the population stability index (PSI) miss non-trivial anomalies, and manual checks run only after something has broken.

Example from the article: after a successful advertising campaign, many customers with a shared attribute arrive at once, and the standard check reports an error in the data although there is none.

Solution in brief

Collapse the customer dimension in SQL: compute descriptive statistics of each variable per month. Fit an Isolation Forest per variable on this monthly history of statistics and turn its decision function into a ranking score. Use the diffi library to show which statistics drove the score. The data steward gets a list of variables and months ranked by anomaly score and starts the investigation there.

Questions this case answers
  • How to detect silent data-quality failures across thousands of variables when labeled anomalies do not exist and per-variable rules do not scale
  • How to rank variables by how anomalous their latest period is, and show which distribution statistic caused it, so a human knows where to look first
  • How to find anomalous variables in a data mart with thousands of columns before they reach ML models?
  • How to monitor data quality when checks are aggregated over millions of customers and manual review comes after the break?

Tools and methods

  • Isolation Forest — unsupervised anomaly detector, fitted per variable on monthly statistics
  • scikit-learn — IsolationForest, decision_function, contamination parameter
  • diffi — Depth-based Isolation Forest Feature Importance: which statistics made a value anomalous
  • Apache Hadoop with SQL — computing the per-month, per-variable statistics
  • Docker — deployment: the container starts right after the data mart is built
Continue reading — it's free

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