flight-delays

Predict whether a 2013 New York flight arrives more than 15 minutes late, from its schedule.

0.7971first run, REJECTED
0.6193last run, APPROVED
target
late
metric
roc_auc
threshold
0.6000
recorded runs
4

Every recorded run

Oldest first. An error stops a model; a warning is worth a look.

  1. REJECTED, full check, score 0.7971

    , test set used 1 time

    Made by the ghost hunter's first run_audit call, on the haunted script.

    • The Prophet at time_hourerror

      81830 test row(s) are earlier than the latest training row (2014-01-01T04:00:00+00:00)

      Fix: split by time with hexperiment.split

    • split_order at train.py:71warning

      transform() is called before the first split

      Fix: this runs before the split; make sure it does not use test rows

    • canary at train.pywarning

      the canary test was not applied: 49090 scrambled test rows ended up in the training set

      Fix: split with hexperiment.split(df), not with your own split

    • metric at metricwarning

      too good to be true: roc_auc 0.7971 is above 0.7500, the most that the threshold 0.6 and the margin allow

      Fix: treat this as a leak until proven otherwise: look for a column that encodes the target

  2. UNVERIFIED, fast check, score 0.6193

    , test set used 2 times

    Made by the save hook after the ghost hunter edited train.py.

    No findings.

  3. APPROVED, full check, score 0.6193

    , test set used 3 times

    Made by the ghost hunter's second run_audit call, on its own fix.

    No findings.

  4. APPROVED, full check, score 0.6193

    , test set used 4 times

    Made by hand afterwards, on the honest reference script kept in the repository.

    No findings.

The fix

haunted/train.py against train.py (the honest script kept in the repository): 17 lines removed, 11 lines added.

1-# Haunted starting point of the demo (Requirements 3.2, 3.3). Do not fix it here.
1+# Honest training script: will a 2013 New York flight arrive more than 15 minutes late,
2+# judged from its schedule alone? (Requirements 3.1, 3.4)
23 #
3-# To run it, copy this file over ../train.py, then run hexperiment on the app.
4-# It is the honest script plus the leaks marked "LEAK:" below.
4+# hexperiment.split puts the latest 20% of flights in the test set. Every learned step
5+# sits inside one Pipeline fitted on training rows only.
56 from __future__ import annotations
67
78 import numpy as np
89 import pandas as pd
910 from sklearn.compose import ColumnTransformer
1011 from sklearn.ensemble import HistGradientBoostingClassifier
11-from sklearn.model_selection import train_test_split
1212 from sklearn.pipeline import Pipeline
1313 from sklearn.preprocessing import OrdinalEncoder
1414
1 unchanged line
1616
1717 TARGET = "late"
1818 CATEGORICAL = ["carrier", "origin", "dest"]
19-NUMERIC = [
20- "month",
21- "day",
22- "sched_dep_time",
23- "sched_arr_time",
24- "distance",
25- "carrier_day_late_rate", # LEAK: The Peeking Spirit. Built from every row's label.
26-]
19+# month and day stay on purpose: a scheduled flight repeats every day with the same
20+# columns, so without a date identical rows would sit in both train and test.
21+NUMERIC = ["month", "day", "sched_dep_time", "sched_arr_time", "distance"]
2722 FEATURES = CATEGORICAL + NUMERIC
23+# Not used: flight and tailnum (identifiers), hour and minute (already inside
24+# sched_dep_time). fetch_data.py removed dep_time, dep_delay, arr_time and air_time:
25+# they exist only after departure.
2826
2927
3028 def drop_seen_test_rows(
40 unchanged lines
7169
7270 def main() -> None:
7371 df = hexperiment.load()
74- # LEAK: same-day late rate of the carrier over all rows, test labels included.
75- day = df["time_hour"].str[:10]
76- df["carrier_day_late_rate"] = df.groupby(["carrier", day])[TARGET].transform("mean")
77- # LEAK: a random split on time-ordered data puts later flights in training.
78- train, test = train_test_split(df, random_state=0) # LEAK: random split
72+ train, test = hexperiment.split(df) # the latest 20% by time_hour is the test set
7973 test = drop_seen_test_rows(train, test, FEATURES + [TARGET])
8074 model = build_model(CATEGORICAL, NUMERIC).fit(train[FEATURES], train[TARGET])
8175 hexperiment.audit(
11 unchanged lines

Model card of the last approved run

Status

Verdict
APPROVED
Mode
full
Run id
20261122-131840-3eec70
Date
2026-11-22T13:19:18Z
hexperiment version
0.1.0

Metric

roc_auc
0.6193
Threshold
0.6000
Result
passed

Split

Data file
data/prepared.csv
Test fraction
0.2
Seed
0
Time column
time_hour

Data

Training rows
261877 (positive rate 23.8%)
Test rows
65469 (positive rate 23.4%)
Training time range
2013-01-01T10:00:00+00:00 to 2013-10-19T18:00:00+00:00
Test time range
2013-10-19T18:00:00+00:00 to 2014-01-01T04:00:00+00:00

Checks

Check Ghost Outcome
row_overlap The Doppelganger passed
target_proxy The Possession passed
temporal The Prophet passed
split_order - passed
canary The Peeking Spirit passed
determinism The Shapeshifter passed

Waivers

No waivers applied.

Test-set uses

The test set has been evaluated 4 time(s), including this run.

Raw files: verdict.json and model_card.md.