AI from scratch · Capstone · Stage 7: production

Capstone: predict broken elevators, live

For a rider in a wheelchair or with a stroller, an out-of-service elevator decides the whole trip. The MTA publishes which elevators and escalators are out and a time it expects them back, and that estimate is longer than the real outage 98% of the time (toolkit 2). A better answer to "will this still be broken in four hours?" would help people plan. This capstone builds it, end to end, on this site's live archive: data, model, honest evaluation, a service, and monitoring. Below is the course's own baseline running on the outages happening right now; your job is to beat it and ship yours.

1. The live board

Every elevator and escalator out of service in the MTA's latest feed, scored by a logistic regression trained on 595 finished outages (toolkit 2's model, exported as 14 weights and 6 scaling numbers). The probability is the model's chance that the outage lasts more than 4 hours from its start. Come back later and see which were right.

Two things the board shows that a notebook hides. Some outages have a reason the model never saw in training ("Capital Replacement": escalators being rebuilt for months); the model treats an unknown category as "nothing known" and its guess means little. And many outages are already past 4 hours: the question for them is settled, which leads to this project's central trap.

The baseline already runs on live data; the capstone is to build a better one and run it the same way, honestly measured.

Why the unfinished outages bias everything: censoring
  1. To train, you need each outage's length. You only know it for outages that have ended. The rest are right-censored: you know they've lasted at least this long, not how long.
  2. Long outages are more likely to still be open when you take a snapshot, simply because they're open longer. In the archive: 27% of finished outages lasted over 4 hours, but 54% of the ones still open have already passed 4 hours.
  3. So training on finished outages only under-represents long ones, and the model learns that outages are shorter than they are. It gets worse the more recent the data: the newest week has the most unfinished long outages.
  4. One fix for this task: an outage that's open and already past 4 hours has a known label (yes), so include it; only the ones open for less than 4 hours are truly unknown. More generally, survival analysis (Kaplan-Meier curves, Cox models) is built for censored durations.
  5. The same trap appears whenever the label takes time: customer churn, loan default, how long a job posting stays open.

2. The milestones

  1. Data. Load outages.csv (or, better, ask for a fresh export of the archive: it grows every day). Look first (toolkit 2): ranges, the two-year-old capital replacements, reasons, duplicates. Decide what to do with censored outages (above). Deliverable: a cleaned table and a paragraph on what you dropped and why.
  2. Baseline and features. The baseline to beat is the board's model (time-split AUC about 0.89). Ideas: the station's history (careful: compute it from the past only, features and leakage), time of day and weekday, the MTA's own estimate (but only the first one it published; the archive keeps the latest, which may have been updated after the fact: leakage), the number of lines. Deliverable: a feature list with, for each, "known at the moment of prediction?".
  3. Honest evaluation. A time split, never random (features and leakage). AUC and a precision-recall curve (chapter 12), a calibration check if you'll show probabilities, and a threshold chosen from costs: a rider told "long" who reroutes needlessly loses minutes; one told "short" who arrives at a dead elevator loses far more. Compare with the baseline on the same test days, paired (Probability 4). Deliverable: one table, one curve, one threshold with its reason.
  4. Model card. Intended use, data, evaluation (overall and per slice: elevators vs escalators, accessible stations), limitations (MLOps). Deliverable: the card.
  5. Service. FastAPI around the model, inputs validated, version returned (serving); or export it to JSON like the board's and score in the browser. Free hosting: a Hugging Face Space (Start 4). Deliverable: a URL.
  6. Monitoring. Log every prediction with its inputs. Each day, when outages end, score yesterday's predictions; track the reason mix's PSI against the training window, weekday against weekday (MLOps). Deliverable: a week of daily AUC and PSI.
  7. Write-up. One page: the problem, what worked, what didn't, what you'd do with more data. Link the notebook, the service and the card. That page is your portfolio piece.

A teammate wants to add the MTA's estimated return time from the archive as a feature: it lifts test AUC to 0.97. What do you check first?

Features and leakage's question for every column: would I know this value at the moment the model has to decide? A revised estimate carries information from the future. Use only the first estimate the feed published.

Seven milestones, each with a deliverable: data, features known in time, honest evaluation, a model card, a live service, a week of monitoring, a one-page write-up.

3. How it's judged

CriterionGood enoughExcellent
Honesty of evaluationTime split; AUC reportedPaired comparison with the baseline, confidence interval, per-slice results, calibration
Leakage and censoringLeaky columns removedCensoring handled and explained; every feature justified as known in time
UsefulnessA thresholdA threshold from stated costs, and what a rider would see
Running systemA notebook that predictsA service with validation and versions, plus monitoring that has caught something
CommunicationA model cardA one-page write-up a non-specialist can follow, with limitations stated plainly

Judged on honesty first: evaluation, leakage and censoring, then usefulness, a running system and clear communication.

Where it breaks: a week of data, and a model riders might trust too much

4. What to carry forward

All lessons: AI from scratch. Data: the MTA elevator and escalator feed, archived by this site; the NYC map shows the same outages live.

Last updated