The big idea
- One feature builder (
features.py) is used both for training and live scoring, so the model sees the same inputs in both: today’s |z_ar|, the volatility of abnormal returns, beta, the market’s absolute move, Wikipedia z-score and spike, log volume ratio, days to and since an event, day of week, month, and online vs store. - Training (
train.py) uses Spark MLlib Pipelines: aVectorAssembler, then logistic regression (with aStandardScaler) or gradient-boosted trees. - The split is by time, never at random: fit on 2016–2022, choose the model on 2023, test once on 2024–2025. Rows whose “tomorrow” falls in the next period are dropped (purged), so no label leaks across the split.
- Big moves are about 5% of days, so the classes are weighted equally during training.
- The alert flags the top 5% of scores (the cut-off is set on the validation year), and the streaming job writes it each micro-batch.
Words you will meet
ROC-AUC
ROC-AUC
The chance that a random big-move day gets a higher score than a random quiet day. 0.5 is guessing, 1 is perfect.
PR-AUC and lift
PR-AUC and lift
Precision (share of flags that were right) across recall levels. Compare it with the base rate; lift is precision divided by the base rate.
Gradient-boosted trees
Gradient-boosted trees
Many small decision trees, each correcting the errors of the ones before it.
Calibration
Calibration
Whether a score of 0.3 really means a 30% chance. These scores are not calibrated (the class weights shift them up), so the dashboard shows shares of flags, not raw scores, as rates.
The picture: The big-move model (Spark MLlib) and the live dashboard
The full diagram and its guide explain every box.Read these files in this order
1
src/ml/init.py
The big-move model (decision 0007): Spark MLlib on the streaming job’s daily output. Read it
2
src/ml/features.py
Features for the big-move model (decision 0007). Read it
3
src/ml/train.py
Train and test the big-move model with Spark MLlib (decision 0007). Read it
Questions you should be able to answer
Why not split the rows at random?
Why not split the rows at random?
Days next to each other are alike. A random split puts tomorrow in training and today in testing, so the model looks better than it would be on the future. A time split tests it like it will be used.
Is 0.69 good?
Is 0.69 good?
It is a real ranking edge over the baseline (0.58), and flagged days are four times as likely to be big moves. It is not a trading strategy: it predicts size, not direction, and ignores costs.
Does Wikipedia attention help?
Does Wikipedia attention help?
Not for this model: the ablation without the two attention features scores the same. That is a finding worth reporting, not a failure.
Ideas to improve it
- Predict the CAR of an upcoming event window directly, with event-level features.
- Calibrate the scores (isotonic regression) so they can be read as probabilities.