← Projects Machine learning Personal project · 2026
Every model fails when the criminals change
Can a model trained on past Bitcoin transactions flag illicit ones in the weeks that follow, and does the transaction graph help? On the Elliptic data, tree models beat every graph neural network, and all of them collapsed after a dark-market shutdown.
- 0.908 → 0.032
- Illicit F1, before → after shutdown
- 0.821 vs 0.672
- Illicit F1, LightGBM vs best GNN
- 0.952
- F1 with a random split instead
- 203,769
- Transactions in the graph
Architecture
- 01 Elliptic graph 49 two-week time steps
- 02 Graph features 190, leakage-safe
- 03 Models trees, MLP, GCN, GraphSAGE, GAT
- 04 Temporal test train 1-34, test 35-49
- 05 Drift analysis shutdown at step 43
The problem
An anti-money-laundering team trains models on labelled history and has to score future traffic, while the people it is trying to catch change their behaviour. I wanted to see how that plays out on real data, and whether the transaction graph helps.
The Elliptic data set has 203,769 Bitcoin transactions in 49 two-week time steps, with 4,545 labelled illicit: scams, ransomware, dark markets and similar.
The constraint
It’s easy to get a great number on this data by evaluating it the wrong way. So every model is trained on time steps 1-34 and tested on 35-49, and all tuning happens inside the training period. Confidence intervals resample the 15 test time steps rather than individual transactions, because transactions in the same step are correlated.
Before comparing anything I reproduced the published baselines from Weber et al. (2019). The random forest matched or beat the paper (F1 0.808 vs 0.788). Logistic regression turned out to be sensitive to the solver, because scikit-learn’s default changed after the paper.
What I built
- Tree models: logistic regression, random forest, XGBoost and LightGBM, the boosters tuned with Optuna.
- Graph neural networks in PyTorch Geometric: GCN, GraphSAGE and GAT, plus an MLP trained in the same loop without edges as a fair control.
- 190 graph features computed from the public graph: degrees, PageRank within the time step, and the mean features of the funding and receiving transactions. They never touch labels. To check for leaks I recomputed them on graphs truncated after steps 10, 34 and 43, and nothing changed.
Results
Trees beat every graph neural network. LightGBM on Elliptic’s features plus mine reached illicit F1 0.821 and average precision 0.809. The best GNN, GraphSAGE, trailed by 0.149 F1. Every GNN, MLP and logistic regression configuration was significantly worse.
My graph features do the work of Elliptic’s aggregated ones. On local features alone the trees scored 0.770-0.782 F1. Adding the graph features lifted them to 0.811-0.813, the same level as Elliptic’s own aggregates.
Message passing helps only when the node keeps its own voice. Against the edge-free MLP, GraphSAGE gained, GAT was level and GCN lost badly. GCN averages each transaction into its neighbourhood, and here the transaction’s own features carry most of the signal. SHAP put 8.8 log-odds on local features against 0.2 on graph structure.
Shortcuts inflate the scores. A random 70/30 split lifted the reference model from 0.821 to 0.952 F1. Adding an illicit-neighbour share computed from all labels, a common feature that reads test labels, added another 0.043.
What broke
Every model collapsed after the dark-market shutdown at step 43. The reference model scored F1 0.908 on steps 35-42 and 0.032 on 43-49, finding 3 of 169 illicit transactions. No model exceeded 0.05.
The new illicit transactions looked licit. Only 9% of their 10 nearest training transactions were illicit, against 68% before the shutdown. Their features moved four times as far from the training illicit class, while licit traffic barely moved.
Retraining before every step with fresh labels did recover, but late. It found only 2 of 77 illicit transactions in steps 43-47, then 43 of 92 in steps 48-49. That’s about ten weeks of new labels before it caught up, and the simulation assumes labels arrive two weeks late. Real AML labels often take months.
Limits
- Small, drifting test set. Only 169 illicit transactions after the shutdown, and wide intervals (0.65-0.90 F1 for the reference model). Neighbouring tree configurations can’t be separated.
- Labels. 77% of transactions are unlabelled and never scored, so results describe the labelled subset, which may be easier.
- Preprocessed features. Elliptic standardised them over the whole period, test steps included.
- Limited tuning. GNNs weren’t tuned beyond early stopping, temporal GNNs weren’t tried, and GCN stays below the paper’s number even with its training schedule.
- Fixed threshold. F1 uses the paper’s 0.5 threshold. An operating point chosen for a review budget could rank models differently, which is why AP is reported too.