big-move-model / README.md
mohummadmahad's picture
Calendar Effects f2eb0c4
68dd4cb verified
|
Raw History Blame Contribute Delete
3.37 kB
---
license: cc-by-nc-4.0
pipeline_tag: tabular-classification
tags:
- spark
- mllib
- gradient-boosted-trees
- tabular-classification
- finance
- event-study
datasets:
- calendar-effects/calendar-effects
---
# Calendar Effects · big-move model
A **Spark MLlib** `PipelineModel` that scores, for each retailer each trading day, how likely tomorrow is
a *big move*: an abnormal return at least 1.96 times its usual size. It runs inside the project's
Spark Structured Streaming job, which writes a watchlist each micro-batch. Data:
[calendar-effects/calendar-effects](https://huggingface.co/datasets/calendar-effects/calendar-effects). Dashboard:
[calendar-effects/dashboard](https://huggingface.co/spaces/calendar-effects/dashboard).
## Model
- **Pipeline:** `VectorAssembler` → `GBTClassifier` (maxDepth=3), trained with PySpark 4.0.4.
- **Features (14):** `abs_z_ar`, `z_ar`, `ar_sd`, `beta`, `abs_mkt_ret`, `z_views`, `attention_spike`, `log_vol_ratio`, `abnormal_return`, `days_to_event`, `days_since_event`, `day_of_week`, `month`, `is_online`.
- **Label:** tomorrow's `|z_ar| ≥ 1.96` for the same retailer.
- **Split by time, never at random:** fitted on 2016–2023, the model and its settings chosen on the
validation year, tested on 2024–2025. Rows whose tomorrow falls in the next period are dropped
(a purged split), and both classes are weighted equally.
- **Alert:** `big_move_alert` = score ≥ 0.759, the top 5% of the validation year's scores.
## Results
On 2024–2025 (18,696 stock-days, base rate 5.2%):
| Model | Features | Split | ROC-AUC | PR-AUC | Precision of top 5% | Lift |
|---|---|---|---|---|---|---|
| gbt | all | test | 0.688 | 0.135 | 21.5% | 4.1× |
| gbt | no_attention | test | 0.689 | 0.133 | 21.6% | 4.2× |
| baseline_abs_z_ar | abs_z_ar | test | 0.582 | 0.082 | 12.6% | 2.4× |
The no-model baseline ranks days by today's `|z_ar|`. Dropping the two Wikipedia features
(`no_attention`) gives the same score, so attention adds nothing to this model.
**Feature importance** (gradient-boosted trees):
| Feature | Importance |
|---|---|
| `month` | 0.166 |
| `log_vol_ratio` | 0.159 |
| `abs_mkt_ret` | 0.158 |
| `ar_sd` | 0.113 |
| `days_to_event` | 0.097 |
| `days_since_event` | 0.079 |
| `day_of_week` | 0.069 |
| `abs_z_ar` | 0.050 |
| `beta` | 0.040 |
| `z_views` | 0.024 |
| `z_ar` | 0.022 |
| `is_online` | 0.019 |
| `attention_spike` | 0.002 |
| `abnormal_return` | 0.000 |
## Use
```python
from pyspark.ml import PipelineModel
model = PipelineModel.load("big_move") # this folder, downloaded
scored = model.transform(features) # columns as built by src/ml/features.py
```
The features must be built exactly as in the project's `src/ml/features.py`. A model saved by
Spark 4.0.4 may not load in an older Spark (the course cluster runs 3.5): retrain there with
`src/ml/train.py` if it does not.
## Limits
A ROC-AUC of 0.69 is a ranking edge, not a trading strategy. The scores are not calibrated
probabilities. The model mostly reacts to what just happened (volume, volatility, the market's move),
so around events its flags often come a day after a burst of big moves starts. Nothing here is
investment advice.
Licence: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/), with credit to the project, not for commercial use.
Built 2026-11-25 from commit `f2eb0c4`.