AskarT commited on
Commit
0db9a73
·
verified ·
1 Parent(s): 90e0d83

Update model card: compact variant

Browse files
Files changed (1) hide show
  1. README.md +46 -15
README.md CHANGED
@@ -29,13 +29,22 @@ model-index:
29
  metrics:
30
  - type: roc_auc
31
  value: 0.786
32
- name: ROC-AUC
33
  - type: recall
34
  value: 0.818
35
- name: Recall @ threshold 0.37
36
  - type: precision
37
  value: 0.306
38
- name: Precision @ threshold 0.37
 
 
 
 
 
 
 
 
 
39
  ---
40
 
41
  # Flight delay risk: CatBoost pipeline
@@ -45,19 +54,37 @@ Binary classifier that estimates the probability that a US domestic flight arriv
45
  time only: airline, origin and destination airports, date, scheduled departure hour, distance and
46
  scheduled flight time.
47
 
48
- This repository holds the single artifact used by the
49
  [Flight Delay Prediction & Risk Analysis](https://github.com/Askar-Turanazarov/FlightDelay-Service)
50
  service (Streamlit UI with SHAP explanations and an FAA-based expected-loss estimate).
51
- Live demo: https://huggingface.co/spaces/AskarT/flight-delay-risk
52
 
53
  ## Files
54
 
55
  | File | Size | Contents |
56
  |---|---|---|
57
- | `model_pipeline_main.pkl` | 433 MB | `sklearn.pipeline.Pipeline` = `FlightFeatureEngineer` (custom transformer) + `CatBoostClassifier`, saved with `joblib.dump(..., compress=3)` |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
- The file is large because CatBoost stores counter (CTR) tables for high-cardinality categorical
60
- features such as `ROUTE` (about 4 200 values) and `DAY`.
61
 
62
  ## Intended use
63
 
@@ -84,15 +111,16 @@ ORIGIN_AIRPORT, DESTINATION_AIRPORT, ROUTE, IS_WEEKEND, IS_NIGHT`.
84
 
85
  CatBoost 1.2.8 on GPU: 2500 iterations, learning rate 0.03, depth 7, `l2_leaf_reg=12`,
86
  `scale_pos_weight=4.2`, Bernoulli subsample 0.8, early stopping on AUC (100 rounds).
 
87
 
88
  ## Evaluation (408 907 hold-out flights)
89
 
90
- | Metric | Value |
91
- |---|---|
92
- | ROC-AUC | 0.786 |
93
- | Recall @ 0.37 (chosen threshold) | 0.818 |
94
- | Precision @ 0.37 | 0.306 |
95
- | Recall / Precision @ 0.50 | 0.660 / 0.396 |
96
 
97
  The decision threshold 0.37 was chosen to favour recall: a missed delay costs the airline more
98
  than a false alarm. Raw `predict_proba` is not calibrated.
@@ -114,7 +142,7 @@ import os, sys, joblib, pandas as pd
114
  from huggingface_hub import hf_hub_download
115
 
116
  sys.path.insert(0, os.getcwd()) # repository root, so that `src.feature_engineering` resolves
117
- path = hf_hub_download("AskarT/flight-delay-catboost", "model_pipeline_main.pkl")
118
  pipe = joblib.load(path)
119
 
120
  flight = pd.DataFrame([{
@@ -130,6 +158,9 @@ print(f"P(delay > 15 min) = {prob:.3f}, flagged = {prob >= 0.37}")
130
 
131
  `DEP_HOUR` / `ARR_HOUR` are the scheduled departure and arrival hours (0–23); `IS_WEEKEND` is 1 for
132
  Saturday and Sunday. The service computes them in `src/app.py` before calling the pipeline.
 
 
 
133
 
134
  ## Limitations
135
 
 
29
  metrics:
30
  - type: roc_auc
31
  value: 0.786
32
+ name: ROC-AUC (full model)
33
  - type: recall
34
  value: 0.818
35
+ name: Recall @ threshold 0.37 (full model)
36
  - type: precision
37
  value: 0.306
38
+ name: Precision @ threshold 0.37 (full model)
39
+ - type: roc_auc
40
+ value: 0.779
41
+ name: ROC-AUC (compact model)
42
+ - type: recall
43
+ value: 0.822
44
+ name: Recall @ threshold 0.37 (compact model)
45
+ - type: precision
46
+ value: 0.297
47
+ name: Precision @ threshold 0.37 (compact model)
48
  ---
49
 
50
  # Flight delay risk: CatBoost pipeline
 
54
  time only: airline, origin and destination airports, date, scheduled departure hour, distance and
55
  scheduled flight time.
56
 
57
+ This repository holds the two model artifacts used by the
58
  [Flight Delay Prediction & Risk Analysis](https://github.com/Askar-Turanazarov/FlightDelay-Service)
59
  service (Streamlit UI with SHAP explanations and an FAA-based expected-loss estimate).
60
+ Live demo: https://flight-delay-askar.streamlit.app · project page: https://huggingface.co/spaces/AskarT/flight-delay-risk
61
 
62
  ## Files
63
 
64
  | File | Size | Contents |
65
  |---|---|---|
66
+ | `model_pipeline_compact.pkl` | 114 MB | **compact variant**, served by the live demo: the same pipeline trained with `max_ctr_complexity=3` |
67
+ | `model_pipeline_main.pkl` | 433 MB | **full variant**, the diploma reference model (`max_ctr_complexity` default = 4) |
68
+
69
+ Both files are `sklearn.pipeline.Pipeline` = `FlightFeatureEngineer` (custom transformer) +
70
+ `CatBoostClassifier`, saved with `joblib.dump(..., compress=3)`, and share data, split, features
71
+ and every other training parameter. CatBoost stores counter (CTR) tables for combinations of
72
+ categorical features (`ROUTE` ≈ 4 200 values × `DAY` × `MONTH` × ...); limiting the combinations to
73
+ three features cuts the model from 433 MB / ~1.5 GB RAM to 114 MB / ~0.6 GB RAM at a cost of
74
+ 0.007 ROC-AUC. The full model was kept unchanged; the compact one was added so that the public demo
75
+ fits the 1 GB free tier of Streamlit Community Cloud.
76
+
77
+ | | Full model | Compact model |
78
+ |---|---|---|
79
+ | Training script | `src/train_final.py` | `src/train_compact.py` |
80
+ | ROC-AUC (408 907 hold-out flights) | 0.786 | 0.779 |
81
+ | Recall / precision @ 0.37 | 0.818 / 0.306 | 0.822 / 0.297 |
82
+ | Recall / precision @ 0.50 | 0.660 / 0.396 | 0.657 / 0.386 |
83
+ | Pipeline on disk | 433 MB | 114 MB |
84
+ | RAM after `joblib.load` / peak while loading | ~1.5 GB / ~2.8 GB | ~0.6 GB / ~0.9 GB |
85
 
86
+ Smaller configurations (`max_ctr_complexity` 2 and 1, 5–52 MB) were also trained and lost
87
+ 0.03–0.05 ROC-AUC; the comparison is in `reports/metrics/compact_experiments.txt` of the service repository.
88
 
89
  ## Intended use
90
 
 
111
 
112
  CatBoost 1.2.8 on GPU: 2500 iterations, learning rate 0.03, depth 7, `l2_leaf_reg=12`,
113
  `scale_pos_weight=4.2`, Bernoulli subsample 0.8, early stopping on AUC (100 rounds).
114
+ The compact variant adds `max_ctr_complexity=3`; nothing else differs.
115
 
116
  ## Evaluation (408 907 hold-out flights)
117
 
118
+ | Metric | Full model | Compact model |
119
+ |---|---|---|
120
+ | ROC-AUC | 0.786 | 0.779 |
121
+ | Recall @ 0.37 (chosen threshold) | 0.818 | 0.822 |
122
+ | Precision @ 0.37 | 0.306 | 0.297 |
123
+ | Recall / Precision @ 0.50 | 0.660 / 0.396 | 0.657 / 0.386 |
124
 
125
  The decision threshold 0.37 was chosen to favour recall: a missed delay costs the airline more
126
  than a false alarm. Raw `predict_proba` is not calibrated.
 
142
  from huggingface_hub import hf_hub_download
143
 
144
  sys.path.insert(0, os.getcwd()) # repository root, so that `src.feature_engineering` resolves
145
+ path = hf_hub_download("AskarT/flight-delay-catboost", "model_pipeline_compact.pkl") # or model_pipeline_main.pkl
146
  pipe = joblib.load(path)
147
 
148
  flight = pd.DataFrame([{
 
158
 
159
  `DEP_HOUR` / `ARR_HOUR` are the scheduled departure and arrival hours (0–23); `IS_WEEKEND` is 1 for
160
  Saturday and Sunday. The service computes them in `src/app.py` before calling the pipeline.
161
+ The two variants give slightly different probabilities for the same flight (this example: 0.469 compact,
162
+ 0.375 full); the service selects the variant with the `MODEL_VARIANT` environment variable
163
+ (`compact` by default, `full` for the diploma model).
164
 
165
  ## Limitations
166