KatInterview

Predicting Late Arrivals: Leakage-Safe Flight Delay Modeling

Machine LearningModel answer
HardModel answerMachine Learningdata-leakagetime-series-validationlightgbm

Last updated

Design a leakage-safe pipeline that predicts 15+ minute late arrivals from pre-departure data: audits, time-based validation, models, explanations, stress tests, and an A/B plan.

An airline analytics team wants a model that flags, ahead of time, domestic flights likely to land at least 15 minutes behind schedule. Predictions may only use information that exists by the scheduled departure time.

You have a historical table of about 50 million flights with these columns:

  • flight_date (YYYY-MM-DD), sched_dep_time (local HH:MM)
  • carrier, dep_airport, arr_airport, route_id, aircraft_tail
  • distance_miles, holiday_flag
  • weather_dep_* and weather_arr_* (temperature, precipitation, visibility)
  • dep_delay_min, arr_delay_min

The label is late15 = 1 when arr_delay_min >= 15, otherwise 0.

Write up how you would approach each of the following.

  1. Exploratory analysis. List the specific checks and plots you would run to detect leakage, drift in the label rate, and rare-category problems. Name at least three concrete leakage risks in these columns and how you would neutralize each one.
  2. Validation. Propose a time-based cross-validation scheme that respects seasonality and avoids look-ahead. Give exact train, validation, and test date windows and justify them.
  3. Modeling. Choose two candidates (one linear, one tree-based). Describe feature engineering (cyclical time encodings, rolling airport and carrier aggregates, weather joins), how you treat class imbalance, your primary metrics, and how you would select and calibrate an operating threshold.
  4. Explainability and robustness. Explain how to use SHAP and partial dependence responsibly on time-ordered data, and describe at least two stress tests of stability across airports or carriers (for example, unseen storms or newly launched routes).
  5. Deployment. Define an inference contract (latency, feature freshness, failure modes) and outline one A/B test, such as proactive rebooking or gate assignment, with success metrics and guardrails.

Hints

Hint 1

Start by fixing a single prediction timestamp (for example a couple of hours before scheduled departure) and ask of every column and every aggregate: is it known by then?

Hint 2

For validation, think expanding windows ordered in time, an embargo gap equal to your longest rolling-feature window, and a final untouched full year so every season is represented.

Hint 3

Keep probabilities honest: avoid resampling, calibrate on recent held-out data, and derive the threshold from explicit costs of a missed late flight versus an unnecessary intervention.

Hint 4

For the A/B test, randomize at a unit that avoids interference (such as flight or hub-day), and pair a primary operational metric with guardrails like cost per action and customer complaints.