Understanding Traffic on the 401, pt 1.
The Government of Ontario runs a fantastic service to monitor the state of traffic jams on the 401: COMPASS Freeway Traffic Management System. So the obvious question becomes, when should I drive home?
Step 1: Get some data
First I ran a cronjob on the server hosting ultrasaur.us, that basically recorded the state of the various stretches of road. It’s been running a few days now, and after 14000 readings, there seem to be the following states for a stretch of road (with counts):
- Express and collector moving slowly (423)
- Express and Collector moving well (7055)
- Express and collector very slow (85)
- Express moving slowly. Collector moving well (205)
- Express moving slowly. Collector N/A (49)
- Express moving slowly. Collector very slow (138)
- Express moving well. Collector N/A (1236)
- Express moving well. Collector moving slowly (435)
- Express moving well. Collector N/A (271)
- Express moving well. Collector very slow (48)
- Express N/A. Collector moving well. (1241)
- Express N/A. Collector moving slowly (129)
- Express N/A. Collector moving well (421)
- Express N/A. Collector very slow (43)
- Express very slow. Collector moving slowly (45)
- Express very slow. Collector moving well (14)
- Express very slow. Collector N/A (75)
- Moving slowly (122)
- Moving well (795)
- N/A (1198)
Notice that there are some near duplicates with double spaces after a period — I’ll convert multiple spaces into singles.
Next I needed to give all of these a value, based on my back of the envelop calculations well means 80+, slowly means 50-80 and very slow means 0 to 50.
Caveats and thoughts:
- the values can’t be exactly calculated, so I’m not going to try,
- one important thing that I want to do is map each status to a unique value so that I don’t lose any data. The key is that the values be in order
- you can see that I’m biased towards the expressway
So values represent the proportional time it takes to travel over a stretch of road (ie higher is worse):
- 100: Moving well
- 101: Express and Collector moving well
- 130: Express N/A. Collector moving well
- 150: Express moving well. Collector moving slowly
- 160: Express moving well. Collector N/A
- 170: Express moving slowly. Collector moving well
- 180: Express moving well. Collector very slow
- 200: Moving slowly
- 201: Express and collector moving slowly
- 210: Express N/A. Collector moving slowly
- 250: Express moving slowly. Collector N/A
- 380: Express moving slowly. Collector very slow
- 410: Express very slow. Collector moving well
- 460: Express very slow. Collector moving slowly
- 501: Express very slow. Collector N/A
- 500: Express and collector very slow
- 510: Express N/A. Collector very slow
- null: N/A (I’m willing to extrapolate a guess at the other N/A’s, but not here)
So this gives me the first chance to make a graph, just over my first 14000 points, here’s the average state of the 401 Westbound over the 24 hours in a day (over a Monday-Wednesday):

The worst time to drive is 4-5pm, but the three hours from 3pm to 6pm seem to be the worst. That’s not much of a surprise (although it’s an hour or so sooner than I expected rush hour to start), but that evening rush hour is so much worse than morning rush hour is a bit of a shock. That 1pm is such a slow time is curious too, I wonder if that bump will go away with more data.
(Data is available to anyone who contacts me, it’ll eventually be available for download)








