New Feature — Detecting Delays

Sunny Ng
Good Service
Published in
3 min readOct 9, 2018

In the last week, the New York City subway system has suffered a couple major delays during peak hours. On Wednesday morning, it was the L train.

Later that afternoon, it was the M train.

Judging from the tweets, what’s worse than having train delays is not knowing when and where they occur. While goodservice.io is pretty good at detecting abnormal headways due to bunching or service after residual delays, it did not do a very good job at detecting delays as they were happening.

A lot of times when you see this, it’s already too late.

In my previous post, I explained how goodservice.io uses countdown clock data (i.e. GTFS-RT) as provided publicly by the MTA, to figure out train headways. What if we use the same information to figure out if trains are not moving?

To illustrate what I mean, remember that goodservice.io uses the differences in estimated arrival times to figure out the headway between each train.

Visual of how goodservice.io calculates headways. Times and trains for illustration purposes only, not to scale.

Using this same information, we can deduce that there’s a delay if the train arrival times keep moving forward.

Estimated arrival times of each train gradually postpone when delays occur.

Now, we keep track of the train that is at the front of each line and if the current estimated arrival time for that train to arrive at the final station exceeds 5 minutes of its initial estimate, then we flag it as a delay.

Putting this code into action, I have been testing this feature for the last week. Yesterday, it was able to catch a delay on the Culver line, affecting the F and G trains.

Notice the small type + 15, which indicate how long the train has been delayed. It is shown separately from the detected headway as it is a different metric.
These screenshots were taken on Monday, October 8, 2018 at 11:49am. So the delay was detected on the F at around 11:38am, and 11:45am for the G.

I was able to detect this delay five minutes before it was post on the MTA website.

This feature not only detects stalled trains, but also when trains are running slower than normal. Either scenario would result in the estimated arrival time being pushed back. By being more proactive about delays, we can plan our trips better.

Try it out and see if there’s a train delay near you on my website at goodservice.io. Feel free to send me your feedback on Twitter to @_blahblahblah. goodservice.io is an open-source project on GitHub.

--

--