hosting/cards/model.md · chapter The dashboard and publishing, file 16 · 71 lines · open in the repository
What it does
A Hugging Face card template: its {placeholders} are filled in by src/hosting/publish_hf.py.Source
hosting/cards/model.md
---
license: cc-by-nc-4.0
pipeline_tag: tabular-classification
tags:
- spark
- mllib
- gradient-boosted-trees
- tabular-classification
- finance
- event-study
datasets:
- {dataset_repo}
---
# 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 {abnormal_z} times its usual size. It runs inside the project's
Spark Structured Streaming job, which writes a watchlist each micro-batch. Data:
[{dataset_repo}](https://huggingface.co/datasets/{dataset_repo}). Dashboard:
[{space_repo}](https://huggingface.co/spaces/{space_repo}).
## Model
- **Pipeline:** `VectorAssembler` → `GBTClassifier` ({params}), trained with PySpark {spark_version}.
- **Features ({n_features}):** {features}.
- **Label:** tomorrow's `|z_ar| ≥ {abnormal_z}` for the same retailer.
- **Split by time, never at random:** fitted on {fit_years}, the model and its settings chosen on the
validation year, tested on {test_years}. Rows whose tomorrow falls in the next period are dropped
(a purged split), and both classes are weighted equally.
- **Alert:** `big_move_alert` = score ≥ {alert_cutoff}, the top {alert_share} of the validation year's scores.
## Results
On {test_years} ({n_test} stock-days, base rate {base_rate}):
| Model | Features | Split | ROC-AUC | PR-AUC | Precision of top {alert_share} | Lift |
|---|---|---|---|---|---|---|
{metrics_table}
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 |
|---|---|
{importance_table}
## 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 {spark_version} 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 {auc_roc} 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 {built} from commit `{code_version}`.