Journal of Science and Transport Technology Vol. 4 No. 2, 1-12
Journal of Science and Transport Technology
Journal homepage: https://jstt.vn/index.php/en
JSTT 2024, 4 (2), 1-12
Published online 10/05/2024
Article info
Type of article:
Original research paper
DOI:
https://doi.org/10.58845/jstt.utt.2
024.en.4.2.1-12
*Corresponding author:
E-mail address:
sanghv@hvtc.edu.vn
Received: 12/03/2024
Revised: 01/05/2024
Accepted: 07/05/2024
Machine Learning Models for Real-Time
Traffic Prediction: A Case Study in Urban
Traffic Management
Van-Sang Ha1,*, Hien Nguyen Thi Bao2
1Department of Economic Information System, Academy of Finance, Hanoi,
Viet Nam
2Department of Corporate Finance, Academy of Finance, Hanoi, Viet Nam
Abstract: This study introduces and evaluates the Long-term Traffic Prediction
Network (LTPN), a specialized machine learning framework designed for real-
time traffic prediction in urban environments. Utilizing a unique combination of
convolutional and recurrent neural network layers, the LTPN model
consistently outperforms established predictive models across various metrics.
It demonstrates significantly lower error rates in both short and long-term traffic
forecasts, highlighting its superior accuracy and reliability. The effectiveness of
the LTPN model is underscored by its robust performance under diverse traffic
conditions, making it a promising tool for enhancing the efficiency and
responsiveness of intelligent transportation systems (ITS). This paper details
the model's architecture, training processes, and a comprehensive comparison
of its predictive capabilities against traditional models, providing clear evidence
of its advantages in real-world applications.
Keywords: Real-time traffic prediction, Intelligent transportation systems,
LSTM, GRU, 1D/2D ConvLSTM.
1. Introduction
Real-time, accurate traffic state prediction is
indispensable for developing Intelligent
Transportation Systems (ITS) that enhance traffic
management and improve service delivery. As
urbanization accelerates worldwide, traffic
congestion intensifies, leading to significant
economic and environmental repercussions.
Effective traffic prediction can drastically enhance
transportation efficiency through dynamic route
planning, coordinated signal control, and enhanced
traveler information systems [1],[2].
Recent advancements have seen the
adoption of various data-driven models for short-
term traffic forecasting, utilizing data from
surveillance cameras, GPS traces, and other
sources. State-of-the-art deep learning models
such as Convolutional Neural Networks (CNN),
Recurrent Neural Networks (RNN), and Graph
Neural Networks (GNN) have demonstrated
promising results [3],[4]. Yet, many studies typically
focus on simulated or singular data sources and do
not sufficiently address diverse traffic conditions in
real-world scenarios. This study aims to bridge this
gap by assembling a comprehensive transportation
dataset from multiple sources, reflecting both
regular and irregular traffic conditions across
various routes. We rigorously assess advanced
deep learning models for traffic forecasting at 15,
30, and 60-minute intervals, providing a detailed
evaluation of their capabilities and extracting
crucial insights on prediction reliability, feature
2
importance, and model deployability in support of
ITS applications [5].
Traffic forecasting is critical for the efficacy of
ITS. Historically, studies relied on statistical
methods like ARIMA and Kalman Filters for traffic
modeling [6]. With the proliferation of data,
machine learning techniques such as regression,
k-Nearest Neighbors (kNN), and Support Vector
Machines (SVM) gained popularity for their ability
to predict traffic short-term. However, these
methods often fall short in capturing complex
spatial and temporal dynamics [7].
In recent years, deep learning has set new
standards in traffic prediction, significantly
outperforming earlier methodologies. Techniques
like RNN, LSTM, and various sequence models are
adept at capturing temporal dependencies, while
CNN architectures are utilized for extracting spatial
features from road networks [8]. Additionally, hybrid
models such as convolutional LSTM and CNN-
LSTM have been developed, alongside Graph
Neural Networks that encode topological
information [9].
Despite these advancements, the focus in
much of the current literature remains on model
optimization, with less emphasis on
comprehensive evaluation across real, varied
traffic data. Our research addresses this deficiency
by conducting an extensive assessment of both
standard and bespoke neural network
architectures on a rich dataset of real-world traffic
conditions. We also introduce a custom
spatiotemporal architecture designed to overcome
the limitations of previous models, advancing the
field of intelligent transportation through more
accurate and reliable traffic forecasting [10]
2. Study Area
The study focuses on a metropolitan region
characterized by a complex network of
transportation routes, experiencing diverse traffic
patterns influenced by both regular commutes and
seasonal variations. This area, covering
approximately 200 square kilometers, includes a
mix of residential, commercial, and industrial
zones, contributing to a heterogeneous traffic
environment.
Geographic Characteristics
The metropolitan area is intersected by
several major highways and arterial roads, which
facilitate significant commuter and commercial
traffic flows. Geographically, it includes several
landmarks such as a major river that bisects the
city, influencing traffic flow and patterns, especially
during peak hours. The area also features varied
topography including elevated regions and flat
plains, which affects road design and traffic
management.
Traffic Characteristics
Traffic within the study area is marked by
high variability:
Weekday Peak Hours: Traffic intensifies
during morning (7:00 AM to 9:00 AM) and evening
(4:00 PM to 7:00 PM) rush hours, predominantly on
highways and major arterial routes leading into and
out of the city center.
Weekend and Holiday Traffic: Noticeable
shifts occur during weekends and holidays, with
increased traffic in recreational and shopping
areas, and reduced flows in commercial districts.
Event-Driven Traffic: The area occasionally
hosts large events which can cause significant,
albeit temporary, changes in traffic patterns,
necessitating dynamic traffic management
solutions.
Weather-Related Variations: Seasonal
weather conditions, including winter snow and
summer storms, significantly influence traffic
behaviors and patterns, impacting traffic
management strategies.
This diverse dataset provides a rich basis for
assessing the effectiveness of predictive traffic
models, as it encapsulates a wide range of factors
influencing traffic flows and allows for testing under
various real-world conditions. By understanding
and predicting these dynamics, Intelligent
Transportation Systems (ITS) can be better
3
equipped to manage and mitigate traffic issues
effectively, enhancing overall transportation
efficiency and safety.
3. Methodology
3.1. Problem Formulation
We formulate the real-time traffic prediction
problem as a supervised machine learning task.
Given historical and current traffic data x(t) of route
r until time step t, the objective is to predict the
traffic state x
(t+k) for the next k steps, where k
corresponds to 15 min, 30 min and 60 min future
intervals.
3.2. Model Framework
We propose a custom Long-term Traffic
Prediction Network (LTPN) leveraging CNN and
LSTM modules for feature extraction and
sequence modelling respectively. the model
architecture:
Model Formulation:
LTPN uses Root Mean Squared Error
(RMSE) as the loss function:
J(θ) = 1/N Σ (Y - Ŷ)2 (1)
Where:
Y: Actual traffic volume
Ŷ: Predicted traffic volume
N: Number of samples
θ: Model weights
Model Architecture:
Input Layer (daytime, weather data)
Conv1D Layer:
16 filters
Kernel size 3
ReLU activation
LSTM Layer:
128 memory units
Tanh activation
Fully Connected Layer:
Output traffic volume prediction
Total Parameters: approx 18K
The model comprises 1D CNN for feature
extraction from input sequences, followed by LSTM
to capture temporal dependencies, and a dense
layer to output multi-step traffic volume prediction.
At each time step t, the model takes as input:
Traffic data sequence (flow, speed etc.) of
previous l intervals x(t-l+1)...x(t)
Time indicators: day-of-week, time-of-day
Weather features
These inputs are passed to a Convolutional
Neural Network (CNN) that detects local spatial
features and extracts high-level abstract traffic
representations.
The flowchart below illustrates the sequential
steps involved in the LTPN-based traffic prediction
process:
Figure 1. Flowchart for the Study
Data Collection
Collect traffic data from multiple sources
such as traffic cameras, inductive loop sensors,
GPS devices, and mobile apps.
Ensure data includes various metrics like
traffic volume, speed, and timestamps, along with
weather conditions and road types for
comprehensive analysis.
Data Preprocessing
Cleanse data by removing anomalies and
outliers.
Normalize data to ensure consistency in
Data Collection
Data Preprocessing
Feature Extraction
Model Training
Validation and Testing
Traffic Prediction
Feedback Loop
4
measurement scales.
Segment data according to the designated
routes to facilitate route-specific analysis.
Feature Extraction
Use statistical and machine learning
techniques to extract relevant features from the
data that influence traffic patterns, such as time of
day, day of the week, and weather conditions.
Apply Conv1D layers to analyze spatial
features and LSTM layers to capture temporal
dependencies, enhancing the model's ability to
predict traffic flow dynamics effectively.
Model Development
Construct the LTPN model integrating CNN
for spatial analysis and LSTM for temporal pattern
recognition.
Configure the network architecture with
appropriate layers, neurons, and activation
functions based on preliminary tests and
theoretical considerations.
Model Training
Split the dataset into training (70%),
validation (15%), and testing (15%) sets.
Train the model on the training dataset while
monitoring performance on the validation set to
tune hyperparameters and prevent overfitting.
Utilize techniques like dropout,
regularization, and early stopping to enhance
model generalization.
Model Evaluation
Assess the trained model on the independent
testing set to evaluate its predictive accuracy and
robustness.
Employ various metrics such as RMSE (Root
Mean Square Error), MAE (Mean Absolute Error),
and potentially R² (Coefficient of Determination) to
quantify model performance.
Validation and Testing
Conduct extensive scenario testing to
simulate different traffic conditions and validate the
model's effectiveness across diverse
environments.
Implement cross-validation techniques to
ensure the model's stability and reliability.
Deployment and Feedback
Deploy the model in a simulated or real-world
environment to predict traffic conditions.
Collect feedback on prediction accuracy and
system performance to identify any areas for
improvement.
Iterative Improvement
Based on feedback and performance data,
make iterative adjustments to the model. This
might include re-training the model with new data,
tweaking model architecture, or refining features
and hyperparameters.
Documentation and Reporting
Document all phases of the project from
conception through deployment, detailing
methodologies, model specifications, performance
evaluations, and case studies.
Prepare final reports and publications to
disseminate findings and contributions to the
broader community..
The output sequence H(t-l+1)...H(t) is fed to
a Long Short-Term Memory (LSTM) network to
model long-term temporal dependencies. Finally,
the LSTM produces the future traffic forecast for
the next k steps x
(t+1)...x
(t+k).
The overall LTPN is trained by minimizing the
mean squared error loss between actual and
predicted traffic states over n samples:
L(θ) = 1/n∑nt=1(x(t+k) - x
(t+k))2 (2)
Our key contributions in the model
architecture are:
Custom 1D CNN to capture inter-dependent
traffic patterns
Multi-step forecasting Horizons - 15 min, 30
min, 60 min
Joint modelling of spatial and temporal
dependencies
4. Experiments and Results
4.1. Data collection
When developing predictive models,
5
particularly those that involve complex datasets
like those used for traffic prediction, the sources of
the data and the processes involved in its collection
are crucial for understanding the quality and
applicability of the resulting model. Here's an
outline of how data sources and collection
processes might be detailed:
Data Sources
For a traffic prediction model, data can be
gathered from a variety of sources, each offering
different insights into traffic patterns:
Traffic Cameras: Mounted at key
intersections and stretches of road, these cameras
provide real-time images and video feeds that can
be analyzed to count vehicles, measure traffic
density, and identify traffic jams.
Inductive Loop Sensors: Embedded in road
surfaces at intersections and on major roadways,
these sensors detect the presence and passage of
vehicles. They are particularly useful for capturing
data on traffic volume and speed at specific points.
GPS Devices: Vehicles equipped with GPS
provide data on speed and location in real-time,
which can be aggregated to analyze traffic flow and
to identify congested areas.
Mobile Apps: Navigation apps collect vast
amounts of data from users, including speed, route
choice, and travel times, which can be used to infer
traffic conditions across the network.
Weather Stations: Since weather conditions
can significantly impact traffic flow and vehicle
behavior, integrating weather data from local
weather stations can enhance the accuracy of
traffic predictions.
Government and Transport Authorities:
Public transport operation schedules, road
maintenance records, and historical traffic incident
reports are valuable for understanding patterns
and planning for regular and exceptional
conditions.
Data Collection Process
The process of collecting this data involves
several steps designed to ensure the
comprehensiveness and accuracy of the
information:
Data Capture: This is the first step where raw
data is gathered from various sources. For
instance, traffic cameras and sensors continuously
transmit data to central servers. GPS data from
vehicles and mobile apps are collected via APIs
that pull data at regular intervals.
Data Integration: Data from multiple sources
is integrated into a unified database. This involves
aligning data from different sources that may not be
in the same format or may not use the same
standards for metrics like time stamps and
geographical coordinates.
Data Cleaning: The collected data is cleaned
to remove inaccuracies, such as duplicate entries,
incorrect or outlier data points, and gaps in data
due to sensor downtime or transmission errors.
Data cleaning is crucial to ensure that the model is
trained on accurate and reliable data.
Data Enrichment: This involves enhancing
the data with additional information that can
improve model accuracy. For example, GPS data
might be enriched with information about road
types and conditions obtained from mapping
services.
Data Storage: The processed data is stored
in databases designed to facilitate quick retrieval
and analysis. This step often involves storing data
in formats and structures that are optimized for the
specific types of queries that will be used in
analysis and model training.
Data Privacy Compliance: Throughout the
collection process, it's essential to comply with data
privacy laws and regulations, especially when
using data sourced from personal devices like
mobile phones. Anonymizing data to remove
personally identifiable information is a critical step
in this process.
4.2. Data Description
We utilize a hybrid traffic dataset for major
highways across 4 routes within a metropolitan
area, recorded from 01/01/2023 to 31/03/2023.