DEV Community

Cover image for Predicting Traffic in the City of Buffalo Using a Neural Network
Mohammed Faisal Khan
Mohammed Faisal Khan

Posted on

Predicting Traffic in the City of Buffalo Using a Neural Network

Every year, transportation departments spend significant resources physically surveying roads to measure traffic. Many roads go unmeasured. We built a Neural Network that predicts whether any road in the Buffalo-Niagara region is Low, Medium, or High traffic — no survey needed.

What it does
Given a road's location, type, direction, and region, the model instantly classifies its traffic level with 75% accuracy(WIP). City planners can use this to prioritize road repairs and signal upgrades. Businesses can use it to evaluate street-level traffic before opening a new location.

How we built it
We trained a feedforward Neural Network in PyTorch on 28,567 real road measurements from Open Data Buffalo. Key steps included log-transforming AADT to handle skew, rule-based feature engineering to reduce high-cardinality columns like road names and municipalities, and adding a custom distance-from-Buffalo feature to capture spatial traffic patterns.

Challenges
The biggest challenge was handling high-cardinality categorical columns with 80+ unique values. We solved this using domain-driven binning — grouping road names into types (highway, avenue, street) and municipalities into geographic regions, which reduced noise and improved model convergence significantly.

Accomplishments
Crossed the 75% accuracy threshold on unseen test data with a lean 4,515-parameter model — proving that simple, well-engineered features outperform complex architectures on structured tabular data.

What we learned
Feature engineering matters more than model complexity. Spending time cleaning and transforming the data — log transforms, geographic groupings, distance features — had a bigger impact on accuracy than changing the network architecture.

Built with
Python, PyTorch, Scikit-learn, Pandas, NumPy, Matplotlib, Seaborn, Open Data Buffalo

Top comments (0)