Back to all projects
Computer Science

AI-Based Traffic Congestion Prediction System

Elijah T 0 views 0 downloadsBSc/BA

Notice: This is a sample project for study and reference. Submitting it as your own work violates most universities' academic integrity policies.

Abstract

About This Research Topic

Most traffic apps tell you what is happening right now, which is a bit like checking the weather after you are already soaked. This project set out to build something genuinely predictive instead, a system that forecasts congestion up to several hours ahead of time, tested four different modelling approaches against each other, and packaged the winner behind a live dashboard.

This article walks through how that system was built, from feature engineering on historical traffic sensor data to a head-to-head comparison of a statistical baseline, Random Forest, LSTM, and a hybrid CNN-LSTM architecture. Readers exploring related technical projects can browse the Computer Science project collection on ScholarNest for comparable studies in machine learning and systems design.

What follows covers the background to AI-based traffic forecasting, the specific problem this project addresses, its objectives and research questions, the key technical terms used throughout, and closes with frequently asked questions for students and developers working on similar predictive systems.

Main Abstract

Traffic congestion imposes substantial economic, environmental, and quality-of-life costs on urban populations, through lost productivity, increased fuel consumption and emissions, and extended commute times, motivating sustained interest in predictive systems capable of forecasting congestion ahead of time to support proactive traffic management and route planning. This study addresses this problem by designing, implementing, and evaluating a machine learning system for short-term traffic congestion prediction that combines historical traffic sensor data with a simulated real-time data feed, moving beyond purely reactive, current-state traffic reporting toward a genuinely predictive capability.

The study adopted the Design Science Research methodology combined with the Cross-Industry Standard Process for Data Mining for the data-driven components of the work. It used the publicly available Metro Interstate Traffic Volume dataset, comprising hourly traffic volume readings from a Minneapolis-St Paul interstate corridor spanning several years, combined with corresponding weather and holiday indicator features, from which a congestion-level target variable (Low, Moderate, High) was derived using volume and historical speed-relationship thresholds. Data were cleaned, engineered with cyclical time-of-day and day-of-week features and lagged historical volume features, and used to train and compare four models: a Seasonal ARIMA statistical baseline, Random Forest, a Long Short-Term Memory network, and a hybrid CNN-LSTM architecture combining convolutional feature extraction with recurrent temporal modelling.

Models were evaluated on both a regression formulation, predicting continuous traffic volume using RMSE and MAE, and a complementary classification formulation, predicting discrete congestion level using accuracy, precision, recall, and F1-score. The hybrid CNN-LSTM model achieved the best performance on both formulations, with a regression RMSE of 312 vehicles per hour and a classification accuracy of 89.4% (macro F1-score of 87.6%) for one-hour-ahead prediction, outperforming the standalone LSTM (RMSE 356, accuracy 85.1%), Random Forest (RMSE 428, accuracy 79.8%), and SARIMA (RMSE 612, accuracy 68.3%). Prediction accuracy degraded gracefully with increasing forecast horizon, remaining above 80% classification accuracy up to a three-hour-ahead horizon before declining more sharply.

The trained model was deployed behind a Flask-based dashboard that ingests a simulated real-time traffic feed, replayed historical data standing in for a live sensor connection, and displays current and predicted congestion levels for the monitored corridor on an interactive map-style interface, with an average end-to-end prediction latency of 45 milliseconds. The study concludes that hybrid CNN-LSTM architectures, informed by both historical patterns and current real-time conditions, offer a practical basis for short-term traffic congestion prediction capable of supporting proactive traffic management, and recommends extension to a road-network-wide, spatially-aware modelling approach as a direction for future work.

Chapter One Preview

Background to the Study

Urban traffic congestion has grown into one of the most persistent challenges facing modern cities, driven by rapid urbanisation, rising vehicle ownership, and road infrastructure that frequently struggles to keep pace with demand. Beyond the immediate frustration of sitting in traffic, congestion carries substantial measurable costs: lost productive hours, increased fuel consumption and associated greenhouse gas emissions, elevated accident risk in stop-and-go conditions, and reduced reliability of public transport and freight logistics operating on the same road network. Traditional traffic management approaches, including fixed-time traffic signal plans and reactive congestion reporting that informs drivers of congestion only once it has already occurred, are increasingly viewed as insufficient for managing the scale and complexity of contemporary urban traffic. The US DOT Intelligent Transportation Systems Joint Program Office has documented this shift extensively in its research on moving cities toward more proactive, technology-enabled traffic management.

Advances in sensor infrastructure, including inductive loop detectors, camera-based vehicle counting, and GPS-derived probe data from connected vehicles and smartphones, combined with progress in machine learning, particularly deep learning architectures capable of modelling the complex temporal and, in network-wide formulations, spatial dependencies present in traffic data, have opened the possibility of moving from reactive to genuinely predictive traffic management. A substantial and rapidly growing body of research, spanning classical statistical time-series methods through to modern deep learning and, most recently, large language model-based approaches, has been devoted to traffic congestion forecasting, with systematic reviews of the field documenting a clear historical progression toward increasingly sophisticated and accurate modelling techniques.

This study contributes to that body of work by designing a traffic congestion prediction system that combines historical traffic pattern data, drawn from the UCI Machine Learning Repository's Metro Interstate Traffic Volume dataset, with a simulated real-time data feed, benchmarking a statistical baseline against increasingly sophisticated machine learning and deep learning architectures, and deploying the resulting model behind a monitoring dashboard capable of displaying both current and multi-horizon predicted congestion levels for a monitored road corridor.

Statement of the Problem

Many existing traffic information systems available to the public and to traffic management authorities remain largely descriptive or reactive in nature, reporting current or very recently observed congestion conditions rather than providing a genuine forward-looking forecast that would allow drivers to adjust their route or departure time, or allow traffic management authorities to proactively adjust signal timing or issue advisories, ahead of congestion onset.

Where predictive systems do exist, published research spans a wide range of modelling approaches and reported accuracies, and it is not always clear from a single study how a given architecture's performance degrades as the prediction horizon extends further into the future, information that is directly relevant to determining how far ahead a given system's predictions can be practically relied upon. This study addresses that gap by developing a system that produces genuine forward-looking, multi-horizon congestion predictions rather than only current-state reporting, and by explicitly evaluating how prediction accuracy degrades as the forecast horizon extends from one to several hours ahead, providing practically relevant guidance on the reliable prediction window for the modelling approach used.

Aim and Objectives of the Study

The aim of this study is to design, implement, and evaluate an AI-based system for predicting short-term traffic congestion using historical traffic pattern data combined with a simulated real-time data feed, and to deploy the resulting model through a monitoring dashboard. The specific objectives are to:

1. Review existing literature and systems relevant to AI-based traffic congestion forecasting.

2. Preprocess and engineer features, including cyclical time and lagged historical volume features, from historical traffic sensor data suitable for supervised model training.

3. Train and compare a SARIMA statistical baseline, Random Forest, LSTM, and a hybrid CNN-LSTM model for both continuous traffic volume regression and discrete congestion-level classification.

4. Evaluate how prediction accuracy varies across increasing forecast horizons, from one to several hours ahead.

5. Implement and evaluate a web-based monitoring dashboard that ingests a simulated real-time traffic feed and displays current and predicted congestion levels.

6. Evaluate the overall system through regression and classification performance metrics, forecast-horizon degradation analysis, system latency testing, and a usability assessment.

Research Questions

1. What machine learning and deep learning techniques have been applied to traffic congestion prediction in existing literature, and what are their reported strengths and limitations?

2. What feature engineering techniques improve traffic volume and congestion-level prediction accuracy on historical traffic sensor data?

3. How do a SARIMA statistical baseline, Random Forest, LSTM, and a hybrid CNN-LSTM model compare for both regression and classification formulations of the congestion prediction task?

4. How does prediction accuracy degrade as the forecast horizon extends from one to several hours ahead?

5. What is the latency and practical usefulness of a real-time monitoring dashboard built around the trained model?

Significance of the Study

This study is significant to several stakeholder groups. To municipal traffic management authorities, it demonstrates a practical, benchmarked approach to short-term congestion forecasting that could inform proactive signal timing adjustment or advisory issuance ahead of predicted congestion onset. To commuters and logistics operators, a genuinely predictive rather than purely reactive congestion information system offers the potential for more informed route and departure-time planning.

To the academic community, the study contributes a same-protocol benchmark comparison spanning statistical, classical machine learning, and deep learning approaches, evaluated across both regression and classification formulations and across multiple forecast horizons, an explicitly multi-horizon evaluation that is not consistently reported in the reviewed literature. Readers exploring related applied statistics or predictive modelling projects may also find the Statistics project collection a useful companion resource. To systems designers, the deployed dashboard illustrates a concrete example of translating an offline-trained multi-horizon forecasting model into a latency-tested, real-time monitoring tool.

Scope of the Study

This study is limited to short-term, one to six hours ahead, traffic congestion prediction for a single monitored road corridor, using the publicly available Metro Interstate Traffic Volume dataset, which provides hourly traffic volume readings alongside weather and holiday indicator features for an interstate corridor in the Minneapolis-St Paul metropolitan area. The study covers the complete pipeline from data preprocessing and feature engineering, through model training, benchmarking, and forecast-horizon evaluation, to the implementation of a simulated real-time monitoring dashboard and system-level latency testing.

The study does not extend to network-wide, spatially-aware traffic prediction across multiple interconnected road segments, integration with live traffic sensor hardware or commercial GPS-probe data providers, or traffic signal control optimisation based on the predictions generated, although these are identified as directions for further work.

Operational Definition of Terms

Traffic Congestion: A condition of impeded traffic flow, operationalised in this study as a discrete Low/Moderate/High congestion-level classification derived from observed traffic volume and historical volume-speed relationships.

Intelligent Transportation System (ITS): A system that applies information and communication technologies, including sensing and predictive analytics, to improve the safety, efficiency, and sustainability of transportation networks.

Forecast Horizon: The length of time into the future for which a prediction is made, for example, one hour ahead or three hours ahead.

Cyclical Time Feature: An engineered feature, such as sine/cosine transformations of hour-of-day, that represents a periodic time variable in a form suitable for machine learning models, avoiding artificial discontinuity at period boundaries such as 23:00 to 00:00.

Lagged Feature: An engineered feature representing the value of a variable, such as traffic volume, at a previous time step, used as an input to predict a future value.

Hybrid CNN-LSTM Model: A deep learning architecture combining convolutional layers, for local pattern extraction, with LSTM layers, for modelling longer-range sequential dependencies, applied jointly to a time-series prediction task.

Real-Time Data Feed: A continuously updating stream of current traffic sensor readings, simulated in this study through replay of held-out historical data standing in for a live sensor connection.

Conclusion

The clearest result from this project is that combining architectures beats relying on any single one. The hybrid CNN-LSTM model, pairing convolutional pattern extraction with LSTM's sequential memory, consistently outperformed a statistical baseline, a tree-based ensemble, and a standalone LSTM across both regression and classification formulations, while still running fast enough for real-time deployment. For any city or research team building similar tools, the more actionable lesson may be the horizon-degradation finding: predictions held up well to about three hours out, which is a genuinely useful planning window before accuracy declines. Students and developers exploring related machine learning or systems projects can find further reference material in the ScholarNest project research library, including comparable studies in computer science and statistics.

Frequently Asked Questions

Which model predicted traffic congestion most accurately in this study?

The hybrid CNN-LSTM model achieved the best performance on both regression and classification formulations, with a one-hour-ahead classification accuracy of 89.4% and a regression RMSE of 312 vehicles per hour, outperforming standalone LSTM, Random Forest, and SARIMA.

What dataset was used to train the models?

The study used the publicly available Metro Interstate Traffic Volume dataset from the UCI Machine Learning Repository, which contains hourly traffic volume readings from a Minneapolis-St Paul interstate corridor alongside weather and holiday indicator features.

How far ahead can the system reliably predict congestion?

Prediction accuracy degraded gracefully with increasing forecast horizon, remaining above 80% classification accuracy up to a three-hour-ahead horizon before declining more sharply.

What methodology guided the system's design?

The study adopted the Design Science Research methodology combined with the Cross-Industry Standard Process for Data Mining for the data-driven components of the work.

What is a hybrid CNN-LSTM model?

It is a deep learning architecture that combines convolutional layers for local pattern extraction with LSTM layers for modelling longer-range sequential dependencies, applied jointly to a time-series prediction task.

How was the real-time dashboard implemented?

The trained model was deployed behind a Flask-based dashboard that ingests a simulated real-time traffic feed, replayed historical data standing in for a live sensor connection, and displays current and predicted congestion levels with an average end-to-end latency of 45 milliseconds.

What feature engineering techniques were used?

The study engineered cyclical time-of-day and day-of-week features to avoid artificial discontinuities at period boundaries, alongside lagged historical volume features representing prior time steps.

What are the limitations of this study?

The study relies on a single-corridor historical dataset rather than a live multi-sensor network, uses a simulated rather than genuinely live real-time feed, and does not model network-wide spatial dependencies between adjacent road segments.

What is recommended for future work?

The study recommends extending the approach to a road-network-wide, spatially-aware modelling approach that captures the influence of congestion on adjacent or connected road segments.

Where can I find more research like this?

Related studies in machine learning, predictive modelling, and applied statistics are available in the Computer Science and Statistics sections of the ScholarNest project research library.

Purchase to unlock the full material.