AskarT commited on
Commit
83386d2
·
verified ·
1 Parent(s): b06fedc

Add model card

Browse files
Files changed (1) hide show
  1. README.md +140 -0
README.md ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ library_name: sklearn
6
+ pipeline_tag: tabular-classification
7
+ tags:
8
+ - catboost
9
+ - scikit-learn
10
+ - tabular-classification
11
+ - flight-delay
12
+ - aviation
13
+ - gradient-boosting
14
+ datasets:
15
+ - usdot/flight-delays
16
+ metrics:
17
+ - roc_auc
18
+ - recall
19
+ - precision
20
+ model-index:
21
+ - name: flight-delay-catboost
22
+ results:
23
+ - task:
24
+ type: tabular-classification
25
+ name: Flight arrival delay (> 15 min) classification
26
+ dataset:
27
+ type: usdot/flight-delays
28
+ name: 2015 Flight Delays and Cancellations (US DOT), 20 % hold-out of the first 2.1 M rows
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
42
+
43
+ Binary classifier that estimates the probability that a US domestic flight arrives **more than
44
+ 15 minutes late** (the FAA definition of a delayed flight) from information known at scheduling
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
+
64
+ Portfolio / educational demonstration of an end-to-end ML service. The model was trained on 2015
65
+ US data; airports, airlines and traffic patterns are those of 2015. It is not an operational tool.
66
+
67
+ ## Training data
68
+
69
+ [2015 Flight Delays and Cancellations](https://www.kaggle.com/datasets/usdot/flight-delays)
70
+ (US Department of Transportation). First 2.1 M rows of `flights.csv`, 80/20 stratified split.
71
+ Target: `ARRIVAL_DELAY > 15` minutes, positive rate 18.9 %. Only pre-departure columns are used:
72
+ `MONTH, DAY, DAY_OF_WEEK, AIRLINE, ORIGIN_AIRPORT, DESTINATION_AIRPORT, SCHEDULED_DEPARTURE,
73
+ SCHEDULED_ARRIVAL, SCHEDULED_TIME, DISTANCE`.
74
+
75
+ ## Features (built inside the pipeline)
76
+
77
+ `hour_sin`, `hour_cos` (cyclic departure hour), `traffic_density` (departures from the origin in
78
+ that month/day/hour), `AIRLINE_FLIGHT_COUNT` (carrier departures from the origin that day),
79
+ `ROUTE` (origin–destination pair), `plan_speed` (distance / scheduled time), `IS_NIGHT`,
80
+ `IS_WEEKEND`. Categorical features passed to CatBoost: `MONTH, DAY, DAY_OF_WEEK, AIRLINE,
81
+ ORIGIN_AIRPORT, DESTINATION_AIRPORT, ROUTE, IS_WEEKEND, IS_NIGHT`.
82
+
83
+ ## Training
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.
99
+
100
+ ## How to use
101
+
102
+ The pickle contains the custom class `FlightFeatureEngineer`, so the service source must be
103
+ importable. Versions matter: Python 3.10, catboost 1.2.8, scikit-learn 1.7.2, numpy 2.2.6,
104
+ pandas 2.3.3.
105
+
106
+ ```bash
107
+ git clone https://github.com/Askar-Turanazarov/FlightDelay-Service.git
108
+ cd FlightDelay-Service
109
+ pip install -r requirements.txt
110
+ ```
111
+
112
+ ```python
113
+ import sys, joblib, pandas as pd
114
+ from huggingface_hub import hf_hub_download
115
+
116
+ sys.path.insert(0, "src") # makes feature_engineering importable for unpickling
117
+ path = hf_hub_download("AskarT/flight-delay-catboost", "model_pipeline_main.pkl")
118
+ pipe = joblib.load(path)
119
+
120
+ flight = pd.DataFrame([{
121
+ "MONTH": 7, "DAY": 15, "DAY_OF_WEEK": 3, "AIRLINE": "AA",
122
+ "ORIGIN_AIRPORT": "JFK", "DESTINATION_AIRPORT": "LAX",
123
+ "SCHEDULED_DEPARTURE": 1800, "SCHEDULED_ARRIVAL": 2115,
124
+ "SCHEDULED_TIME": 375, "DISTANCE": 2475,
125
+ }])
126
+ prob = pipe.predict_proba(flight)[0, 1]
127
+ print(f"P(delay > 15 min) = {prob:.3f}, flagged = {prob >= 0.37}")
128
+ ```
129
+
130
+ `SCHEDULED_DEPARTURE` / `SCHEDULED_ARRIVAL` are in HHMM form as in the source data.
131
+
132
+ ## Limitations
133
+
134
+ * 2015 US data only; no weather, no real-time information.
135
+ * Probabilities are not calibrated; the service shows them next to the 18.9 % base rate.
136
+ * Traffic features fall back to 1 for airport/day/hour combinations unseen in training.
137
+
138
+ ## Author
139
+
140
+ Askar Turanazarov, Data Science diploma project, 2026. MIT license.