100 beginner machine learning projects with runnable Python code, tests and honest case studies. By Networkers Home, Bangalore.
This small teaching project builds a short-horizon traffic-volume baseline using synthetic aggregate road measurements (no personal traces). It demonstrates how to prepare lag features, add simple calendar inputs, compare to a persistence baseline and evaluate performance on held-out future periods and held-out road segments. The model produces planning estimates and flags stale data warnings; it does not perform any automatic traffic-control actions.
The dataset is synthetic but designed to resemble aggregate segment counts by hour for multiple connected road segments. Each row is an hourly aggregate vehicle count for a segment, with a timestamp, segment id, an incident indicator inserted for some hours, and calendar fields. This is NOT real travel-trace data; it uses only synthetic, aggregate counts generated inside the code.
Run the project directly with Python:
python project.py
It prints a JSON object with evaluation metrics and a small planning table (as JSON-friendly numbers). Change the seed argument in run(seed=…) if you want different random draws.
Run the unit tests with pytest in the project directory:
pytest -q
The tests import run from project.py and validate keys, numeric ranges, determinism and a conservative performance floor.
This project uses synthetic aggregate counts and simple temporal structure. It omits real-world spatial correlations between connected links beyond sharing a base signal generation process, and it does not model routing, lane-level details or complex incidents. The baseline is a short-horizon lag-feature RandomForest and a persistence comparator; more advanced temporal models (e.g. sequence models or graph-based spatiotemporal models) would be needed for production-grade forecasting.
Possible improvements include: adding explicit spatial correlation between neighbouring segments, using probabilistic forecasts, engineering richer incident features (severity, duration), validating on real aggregate traffic counts and extending the horizon and evaluation to multiple days and holidays.
Full case study, build steps and evaluation checks: Traffic prediction system on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code