Uber Cape Town Road Incidents
Predicting when and where road incidents will occur next in Cape Town. The challenge was not just building a classifier — it was transforming raw geospatial and temporal data into features that capture the rhythm of a city's road network and the conditions under which incidents cluster.
TL;DR: In geospatial incident prediction, the most powerful features are not the static road characteristics — they are the dynamic temporal patterns that capture how a road segment's risk profile changes throughout the day and week. History repeats on roads just as it does in financial markets.
The Problem
Cape Town's road network is complex — a mix of highways, arterial roads, and residential streets, each with different risk profiles at different times of day. The competition asked us to predict which road segments would experience incidents in upcoming time windows.
What made this problem interesting was the sparsity: incidents are rare events distributed across hundreds of road segments and dozens of time slots. A naive model would simply predict "no incident" everywhere and achieve high accuracy while being completely useless for deployment.
The real challenge was engineering features that could distinguish high-risk segment-time combinations from the vast majority of safe ones, using only historical incident data, road characteristics, and Uber Movement travel time patterns.
The Approach
I approached this as a structured classification problem with heavy emphasis on feature engineering. The raw data needed substantial transformation before any model could learn meaningful patterns.
Temporal Feature Engineering
Extracted hour-of-day, day-of-week, month, and holiday indicators. Created rolling incident counts per segment over 7-day, 14-day, and 30-day windows. Peak hours and weekend flags captured the rhythm of when roads become dangerous.
Geospatial Context
Road segment characteristics — length, number of lanes, speed limit, intersection density — served as static risk factors. Segments near highway on-ramps or major intersections carried structurally higher risk regardless of time.
Uber Movement Integration
Travel time data from Uber Movement provided a proxy for congestion. When travel times spike on a segment, the probability of incidents increases. I created congestion ratio features comparing current travel times to free-flow baselines.
Sampling Strategy
With extreme class imbalance, I implemented stratified sampling to ensure the model saw enough positive cases during training. Combined with careful threshold tuning during evaluation, this prevented the model from defaulting to the majority class.
Implementation
The pipeline was built in R with a clear separation of concerns: configuration, data loading, cleaning, feature engineering, train/test construction, sampling, modeling, and evaluation — each in its own script.
XGBoost served as the primary model, with hyperparameters tuned via cross-validation. The feature importance analysis revealed that temporal recurrence features (rolling incident counts) dominated, followed by congestion proxies and road geometry.
The final submission ranked 13th out of 113 successful submissions, placing in the top 11%. Notably, only 113 out of 711 total competitors managed to submit valid predictions, reflecting the difficulty of the problem's data processing requirements.
Key Takeaway
Design insight: In geospatial incident prediction, the most powerful features are not the static road characteristics — they are the dynamic temporal patterns that capture how a road segment's risk profile changes throughout the day and week. History repeats on roads just as it does in financial markets.
Comments
FAQ
What is the key takeaway from "Uber Cape Town Road Incidents"?
In geospatial incident prediction, the most powerful features are not the static road characteristics — they are the dynamic temporal patterns that capture how a road segment's risk profile changes throughout the day and week. History repeats on roads just as it does in financial markets.
Who wrote this and what is it about?
This was written by Mahmoud Trigui, Senior Data Scientist. Predicting when and where road incidents will occur in Cape Town. Multi-source geospatial feature engineering, temporal pattern extraction, and XGBoost ensemble. Ranked 13th out of 113 successful submissions (711 total competitors). Zindi, January 2020.