Traffic Prediction with Deep Neural Network Regression

TallyGo
4 min readDec 13, 2018

--

If your friend was visiting from out of town and wanted to know what traffic would look like on the 101 South, before you answered, you would think about two things: 1.) What traffic looks like now, and 2.) What’s typical for this time of day. That’s exactly what we did when we set up our deep neural network to learn from past traffic and create a prediction for future conditions.

Here’s what traffic looked like on the 101 South on Friday, Oct 3, 2018:

Friday Oct. 5, 2018, Speed Readings

Time is on the vertical axis, from early morning at the top to midnight on the bottom. Location along the 101 South is plotted on the horizontal with Thousand Oaks in the west on the left side, then sensors moving east across the San Fernando Valley as we move right, and finally sensors coming into downtown LA as we get to the right side of the chart. Light means fast moving traffic, dark means slow. You can tell this chart is of a Friday because the slow traffic continues past the evening rush hour into late night (on the bottom right of the chart) as people join the Hollywood nightlife.

We encoded the time of day and day of the week into a feature vector and trained a deep neural network (DNN) with a mix of convolutional and dense layers. Then we created a speed prediction on the 101 South using only this time of day information:

Friday Oct 5, Time Cues For Prediction

The DNN “figured out” what was typical for a Friday, including the nightlife traffic. Then we made another prediction of freeway speeds, but this time using only immediate near history of traffic conditions. For our training set, each feature vector was all the speeds each sensor had recorded in the past half hour, training the DNN on what ended up happening five minutes into the future.

Friday Oct 5, Near History Cues For Prediction

Because this is a prediction only five minutes into the future, it holds pretty close to the speeds it has just seen in the feature vector (what’s plotted in the “Actual” graph). But because a good prediction depends on both what the current conditions are, and what might typically develop given the time of day, the two prediction DNN systems were merged into one DNN and then trained. Here’s the combined prediction using both the time and sensor history features:

Friday Oct 5, Combined Time and History Cues

By combining the two prediction systems into one, we’re allowing the DNN to decide when, where, and how to balance near historical information with what’s typical for that day. Here’s another example from Wednesday, Oct. 3, 2018, but with predictions made 30 minutes into the future. Here’s the prediction with only time of day feature vectors:

Wednesday Oct 3, Time Cues For Prediction

Here’s the prediction with only recent sensor readings feature vectors:

Wednesday Oct 3, Near History Cues For Prediction

Here’s the prediction combining both networks before fitting to the actual speeds observed 30 minutes later:

Wednesday Oct 3, Combined Time and History Cues

The combined model shows that it relies heavily on the sensor readings it has seen on the freeway from 30 minutes before, but in the morning it assumes traffic will start to get bad even before slow speeds show up in the near history, based solely on what’s typical for a Wednesday. The combined model learned that at 5:30 AM, even if the freeway is clear, traffic will start slowing around 6 AM.

Here are the actual speeds for Oct. 3:

Wednesday Oct 3, 2018, Speed Readings

We hope this window into how we create graph forecasts using deep neural network regression was interesting. We enjoy swimming in this data because better predictions mean we can create better routes, taking into account the speed of every road at every time.

This work was done using the Keras package for Python, with a TensorFlow backend. A big thanks to the developers who created these amazing open-source tools!

By Thomas Haley, TallyGo Data Science

--

--

TallyGo

Maps and navigation in your app, before you leave the office today.