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
- 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.
- 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.
- 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.
- 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.
- The same trap appears whenever the label takes time: customer churn, loan default, how long a job posting stays open.
2. The milestones
- 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. - 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?".
- 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.
- Model card. Intended use, data, evaluation (overall and per slice: elevators vs escalators, accessible stations), limitations (MLOps). Deliverable: the card.
- 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.
- 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.
- 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?
- Nothing: ship it
- Whether more data makes it even better
- Whether that estimate was known when the outage started: the archive stores the latest estimate, which may have been revised after the outage was already long
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
| Criterion | Good enough | Excellent |
|---|---|---|
| Honesty of evaluation | Time split; AUC reported | Paired comparison with the baseline, confidence interval, per-slice results, calibration |
| Leakage and censoring | Leaky columns removed | Censoring handled and explained; every feature justified as known in time |
| Usefulness | A threshold | A threshold from stated costs, and what a rider would see |
| Running system | A notebook that predicts | A service with validation and versions, plus monitoring that has caught something |
| Communication | A model card | A 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
- One week is one week. The archive's finished outages mostly started in a single week of October. Holidays, winter storms and summer heat are all unseen. Say so in the card, and keep collecting: the MLOps lesson's monitoring is also how the training set grows.
- Unseen categories. A new reason, station or equipment type gets no learned weight. Flag those predictions as low-confidence (the board does), rather than showing a number.
- False confidence. "93% chance it's back within 4 hours" can send a wheelchair user to a dead elevator 7% of the time. For accessibility, a cautious threshold and plain words ("often fixed within hours, but plan an alternative") may serve riders better than a precise-looking probability.
4. What to carry forward
- Every skill on the path, in one project: data, features, evaluation, deployment, monitoring, communication.
- Labels that take time to arrive are censored: handle them, or the model learns a biased world.
- Ship a baseline early, measure everything against it, and keep it running while you improve on it.
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