> ## Documentation Index
> Fetch the complete documentation index at: https://calendar-effects.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 2026-11-24 · Mahad · 38 retailers, a Spark MLlib big-move model, and a live dashboard (branch `mahad/ml-scale-dashboard`)

* **Done:**
  * **Bigger data (decision 0009):** 28 more retailers in `config/retailers.csv` and their Wikipedia titles in `config/wiki_articles.csv`, giving 38 retailers + SPY.
    * Every ticker was checked before it was added: all 2,514 trading days on Yahoo, and Wikipedia views in every month of 2016–2025.
    * Williams-Sonoma, Casey's and Burlington were renamed on Wikipedia, so both titles are listed and their views added together. Boot Barn was left out, since it had no article before 2021.
    * The ETL was re-run: `clean/prices.parquet` and `clean/master.parquet` now have 98,046 rows (was 27,654).
  * **Machine learning (decision 0007):**
    * `src/ml/features.py`: one feature builder shared by training and live scoring.
    * `src/ml/train.py`: Spark MLlib. Logistic regression and gradient-boosted trees on the stream's daily output, with a purged time split (train 2016–2022, choose on 2023, test 2024–2025), class weights, an attention ablation and a no-model baseline.
    * `src/streaming/job.py` now loads the saved model and writes `data/stream/predictions/` each micro-batch (scoring runs in the JVM).
  * **Live dashboard (decision 0008):** `src/dashboard/app.py` (Streamlit, `streamlit run src/dashboard/app.py`). It shows today's alerts, tomorrow's watchlist, event CARs as windows close, and charts. It reads only finished micro-batches.
  * **`run_everything.sh`** now also runs the batch study (`car.py`, `stats.py`, `charts.py`), the stream-vs-batch comparison and the model (`--skip-ml` skips it), then prints how to open the dashboard. Kafka mode uses `--max-per-trigger 390` (10 days × 39 tickers).
  * **Docs:**
    * four new contracts (`stream_predictions`, `ml_metrics`, `ml_test_predictions`, `ml_feature_importance`), in `docs/data-contracts.md` and `contracts.py`;
    * `common.study` ML settings and `common.settings` model paths;
    * README "For markers" and run steps, and AGENTS.md layout;
    * architecture diagrams updated to the new numbers, plus pair 11 (model and dashboard).
  * **Tests:** `tests/test_ml_features.py` (7) and `tests/test_dashboard.py` (3, including a headless run of the app). 115 pass.
* **Results:**
  * **Scale:** the local streaming run matches the direct computation on 95,190 stock-days and 2,280 event CARs (largest difference about 2e-16, 0 rows dropped). The comparison with the answer key gives 2,280 of 2,280 windows equal, and the same significance call in 2,242 of 2,242.
  * **Batch study at 38 retailers:**
    * store retailers' mean CAR over all events is +1.1% (clustered p = 0.033);
    * Halloween online −3.6% (p = 0.044), and online minus store −4.5% (p = 0.02);
    * Black Friday stores +2.5% (p = 0.094).
  * **Model** (test years 2024–2025, 18,696 stock-days, base rate 5.2%):
    * gradient-boosted trees: ROC-AUC 0.688, PR-AUC 0.135, and 21.5% of its top 5% flags are big moves (4.1× lift);
    * the no-model baseline (today's |z\_ar|): 0.582 and 2.4×;
    * without the attention features the score is the same, so Wikipedia attention adds nothing to this model;
    * the top features are month, log volume ratio, the market's absolute move, ar\_sd, and days to or since an event.
  * Training takes about 1 minute locally. A full `run_everything.sh --skip-etl` takes about 20 minutes at 38 retailers.
* **Decisions:** 0007 (big-move model), 0008 (dashboard), 0009 (38 retailers), all Proposed.
* **Contracts:** `stream_predictions`, `ml_metrics`, `ml_test_predictions`, `ml_feature_importance` added. Existing contracts are unchanged.
* **Next:**
  1. Review and merge the branch into `main` (AGENTS.md rule 6).
  2. Re-run the cluster test at 38 retailers, and train the model there (a Spark 4 model may not load in the cluster's Spark 3.5).
  3. Use the dashboard in the demo video.
* **Blocked on / needs from others:**
  * **Anushiya:** please review the `run_everything.sh` changes (steps 7–9; this covers the pending #11 update).
  * **Areej:** the batch numbers changed with 38 retailers, so re-run `car.py`, `stats.py` and `charts.py` before writing the results. Decision 0009 lists the new findings.
  * **Sanchi:** the results section can use the model table above, `data/results/charts/ml_roc_pr.png` and `ml_feature_importance.png`.
  * **Everyone:** run `pip install -r requirements.txt` again for `streamlit`. Agree on decisions 0007–0009, or say what to change.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.