1. Introduction
Managing the transportation system requires high-quality real-time data. As the intensity and density of traffic flow increase, the demand for effective traffic interventions also rises [
1]. Intelligent transportation systems (ITS) use various technologies—wireless networks, sensors, mobile phone data, and GPS. ITS empowers diverse components within the transportation system—vehicles, roads, traffic lights, message signs, etc. [
2]. Consequently, this results in increased capacity of the transportation network and higher safety and comfort [
3]. In [
4], the authors introduced an intelligent transportation system called “Itssafe”, designed to enhance traffic safety and efficiency. The system aims to use modern technologies and analytical tools for monitoring and managing traffic. It leads to reducing the risk of traffic accidents and improving traffic flow. Suitable data collection methods are crucial for such systems, often utilising various types of sensors.
Sensors are one of the essential components of intelligent transportation systems. They help to obtain data in many areas of transportation, including traffic flow monitoring, accident detection, emission monitoring, and other transportation aspects [
5]. According to [
6], sensors are also essential for adaptive traffic light control at intersections, monitoring road surface conditions [
7,
8], and measuring the weight of moving vehicles [
9].
The selection of an appropriate sensor type depends on the specific environmental conditions of the application [
10]. Typical systems for vehicle detection and classification primarily utilise ultrasonic sensors [
11], acoustic sensors [
12], infrared sensors [
13], ultrasonic sensors [
14], inductive loops [
15], magnetic sensors [
16], video surveillance [
17], laser sensors [
18], and microwave radars [
19]. In the past, pneumatic sensors were also used to measure the traffic flow characteristics using a hose placed on the road. Video detection or other aforementioned sensors have already surpassed this outdated technology [
20]. All sensors measure physical characteristics, such as sound waves, light emissions, changes in magnetic fields, etc. However, correct processing of these input variables determines macroscopic data—speed, intensity, and traffic flow density [
21]. These characteristics can be obtained not only from traffic sensors but also, for example, from road users’ mobile devices [
22]. Apart from these fundamental characteristics, some cases require additional information—vehicle classification, number of axles, vehicle weight, and car presence in a parking space or in front of an intersection [
23]. In some applications, the direction of travel is also essential, especially for wrong-way vehicle detection systems [
24].
The system must be capable of receiving information from multiple sensors at once. Therefore, wireless sensor networks (WSNs) connect all sensors to one consistent network. WSNs consist of remote sensor devices positioned at various locations within the road network, communicating wirelessly with each other. These sensors collect crucial traffic data, which is then processed and analysed to enhance traffic management, predict traffic situations, optimise traffic flows, and improve road safety. WSNs in transportation provide an effective tool for obtaining real-time information [
25]. WSNs are used not only in transportation for traffic optimisation [
26] but also in many other sectors—military [
27,
28], healthcare [
29,
30], and more.
Figure 1 illustrates the basic diagram of WSN.
The principle of operation of magnetic sensors is simple—they operate based on detecting magnetic fields disrupted by metal parts of passing vehicles. It induces an electrical current in the sensors as the magnetic field changes [
31]. With proper system calibration, magnetic sensors can measure speed, traffic flow intensity, and congestion [
32] and also categorise vehicles by length [
33,
34,
35].
However, magnetic sensors also have disadvantages. There may be discrepancies in the vehicle detection process because there is a problem with a blind zone of the geomagnetic signal. This problem can occur between vehicle axles, specifically when the sensor detects longer vehicles with extended chassis—trucks, buses, and SUVs. Consequently, multiple detections are also possible during low-speed manoeuvres. As illustrated in
Figure 2, the bus shows increased magnetic interference signals from its front and rear wheel areas. Nevertheless, a blind zone between the front and rear axles within the magnetic signal may lead to incorrect vehicle identification by the sensor.
The suitability of using a specific type of sensor depends on many application conditions. From the perspective of evaluating the measured data, it is necessary to find procedures and algorithms that ensure the most accurate results [
36].
The global outbreak of the COVID-19 pandemic has reshaped the dynamics of urban life in unprecedented ways. Cities worldwide experienced significant disruptions in various sectors, including transportation. The impact of the COVID-19 pandemic on mobility was extensive, mainly due to the implementation of widespread lockdowns, social distancing measures, and other anti-pandemic interventions. Quarantine measures, social distancing, travel restrictions, and movement bans reduced mobility worldwide.
Like many others, the city of Zilina in Slovakia faced the intricate challenge of managing urban mobility during these extraordinary times. Understanding the impacts of the pandemic on traffic and transportation systems is crucial for effective urban planning and policymaking. This study delves into the nuances of traffic dynamics, with a particular focus on the pandemic period. We will examine how traffic density changed during the analysed period.
In response to urban traffic’s complex and dynamic nature, this research employs advanced artificial intelligence models, specifically neural networks, to model and analyse the intricate interplay between various factors influencing traffic. Neural networks have proven invaluable tools in capturing and understanding complex relationships within large datasets, making them well-suited for modelling the multifaceted aspects of urban mobility.
The study leverages real data from a network of sensors strategically placed throughout Zilina, capturing the movements of vehicles across key intersections. This article focuses exclusively on magnetic sensors integrated into WSN. These sensors provide real-time information, allowing for a comprehensive analysis of traffic patterns. Importantly, the study incorporates variables related to the COVID-19 pandemic, sourced from international databases tracking government responses and public health measures. By integrating pandemic-related variables into the neural network model, we aim to analyse how anti-pandemic measures have influenced traffic flow. The study not only seeks to clarify the pandemic impacts but also brings valuable insight for future urban planning in a post-pandemic era.
This research also shows the potential of neural network models in modelling the complexities of traffic dynamics. Beyond the immediate implications for Zilina, the findings of this study may inform broader discussions on resilient and adaptive urban transportation systems in the face of unforeseen challenges.
The following sections of the article correspond to the structure of a scientific study. The Literature Review section captures the current state of knowledge in the research area. The Methodology and Data section describes the data used in the study and the process of its thorough preparation and also describes the research methodology and briefly explains the modelling techniques used in the study. In the Results section, some of the study’s findings are presented. The Discussion section discusses the strengths and weaknesses of the study and its potential future directions. The final section contains the conclusions.
2. Literature Review
Urban mobility is a critical aspect of modern cities, impacting transportation efficiency, environmental sustainability, and overall quality of life. Understanding urban mobility patterns becomes increasingly important as cities continue to grow and evolve. In recent years, advancements in sensor technology and data collection have allowed researchers to delve deeper into the dynamics of urban mobility.
To model traffic flow, researchers have turned to deep learning techniques. In [
37], the authors comprehensively reviewed the latest advancements in utilising neural network algorithms to address various traffic forecasting issues, including road traffic flow, speed prediction, and passenger flow estimation. The survey also examines the advantages and disadvantages of graph neural networks compared to other deep learning models for traffic forecasting. A study by [
38] offers an overview of deep learning techniques used in traffic flow prediction models and highlights the influence of various factors on the performance of these models in different scenarios.
Thanks to the rapid evolution in deep learning and neural networks, better evaluation of measured data, their interpretation, and future prediction should be achieved. However, traditional machine learning models often struggle with the complex association features between road sections, especially when dealing with the exponential growth in the number of vehicles. In their study [
39], the authors proposed a method for sharing information between road segments and used it for their prediction model, which combines convolutional neural networks and road segment grouping algorithms to predict traffic congestion more accurately. Similarly, in [
40], the authors explored neural network-based traffic-flow prediction models. The authors used artificial neural networks to model traffic volume in major junctions in Istanbul. In [
41], the authors aimed their study at demonstrating machine learning algorithms’ ability to predict road traffic based on data from software traffic simulators in case of temporal unavailability of real data from road sections. Unlike microscopic traffic simulation, these neural network-based algorithms can work in real-time, making them suitable for applications such as determining variable message road sign speeds.
In [
42], the authors explored the possibilities of incorporating neural networks into processing data from traffic sensors. The study aimed to optimise the monitoring system and increase its efficiency and reliability in detecting and tracking vehicle movement on roads. In [
43], the authors introduced a vehicle detection algorithm capable of tracking multiple vehicles simultaneously. They also developed a real-time vehicle tracking counter that integrates vehicle detection and tracking algorithms to measure traffic flow accurately. These models are based on deep learning algorithms and achieved an average accuracy of 92% with an average processing speed of nearly 38 frames per second. In [
44], the authors introduced automatic vehicle detection and classification using deep neural networks. Their models are trained on the data from the Bangladeshi vehicle images dataset, achieve an accuracy of over 83% and are highly usable in solving minor incidents on streets in order to avoid collisions, accidents or even human fatalities. In their study [
45], the authors discussed using a wavelet neural network in traffic flow prediction tasks focused on the prediction for weekdays and weekends separately. Their model achieves a lower level of error in its predictions. In their study [
46], the authors also considered temporal correlation between the data used for traffic flow predictions. In their model, the authors developed attention mechanisms to capture the spatiotemporal correlations of the data sequences to achieve accurate traffic flow predictions and make more rational decisions.
3. Methodology and Data
3.1. Data Used in the Study
The study is conducted using real data from sensors installed at intersections in the city of Zilina. The data are publicly available from the website
https://dashboards.clevernet.sk (accessed on 1 February 2023), where, among other information, the numbers of vehicles passing through individual installed sensors are provided. Nine areas along significant streets in the city are monitored, all in both inbound (toward the centre) and outbound (away from the centre) directions [
47]. The list of monitored streets and the number of sensors is detailed in
Table 1.
In this study, we calculated the total vehicle numbers at each sensor within an intersection for simplification. Therefore, in the following text, when we refer to a “sensor”, we mean the cumulative number of vehicles, and we will denote these sensors by the numbers assigned to them in the first column of
Table 1. The location of the sensors within the city is illustrated in
Figure 3.
In the study, we utilised data from 6 June 2021 to 5 August 2022. This timeframe was chosen to ensure that all sensors were already operational, as some were installed later or as additional units, ensuring comparability of analyses. The end date of the analysed period was selected as the most recent date for which data were available when the analysis commenced.
The number of vehicles passing each sensor is monitored in 5-min intervals. For this study, we aggregated vehicle numbers into 15-min time intervals, resulting in a total of 365,400 records for the observation period. Vehicles passing through the sensors are categorised into four groups: cars, vans, trucks, and unknown. The type of vehicle is automatically determined by the sensor based on its dimensions. The types of distinguished vehicles are illustrated in
Figure 4.
Additionally, speeds at which vehicles pass through the sensors are recorded, distinguishing speeds into categories of up to 30 km/h, between 30 and 60 km/h, and above 60 km/h. The lane through which the vehicle passes (left, middle, right, if such lanes exist at the given intersection) is also recorded. However, for this study, we did not differentiate between vehicle speeds or lanes. Therefore, vehicle numbers were only distinguished by vehicle type and direction, aggregated across all speeds and lanes.
Therefore, the entire database for this analysis is composed of records from 9 sensors, each in two directions (in and out), for each of the four types of vehicles (cars, vans, trucks, unknown). Therefore, in total, the database contains 72 variables, which we consider dependent (target) variables for this study. The list of target variables and their labels used in the study is in
Table 2.
In this study, we focus on creating a mobility model, specifically the model for predicting the number of vehicles moving at these key intersections in Zilina. The model is constructed using the method of neural networks, which is explained in more detail in the methodological section. The input variables for this model include variables whose names and explanations are provided in
Table 3.
In
Table 3, several variables are mentioned that we used to describe the situation during the COVID-19 pandemic in Slovakia. These variables are internationally published on the COVID-19 Government Response Tracker website [
48], which seeks to quantify the pandemic situation and the anti-pandemic measures implemented by various countries worldwide using multiple indicators. This project has tracked anti-pandemic measures since 1 January 2020, in more than 180 countries worldwide. In total, 21 indicators are calculated, representing the scale of the implemented measures. These indicators were published until the end of the year 2022. In the study, we used the values of these indices for the entire Slovakia, as it is impossible to obtain values for smaller territorial units.
The indicators can be categorised into four primary groups:
Restrictions and closures: These indicators capture data on policies related to restrictions and closures, including school shutdowns and movement limitations.
Economic policies: These indicators document economic measures, such as income support for citizens and the provision of foreign aid.
Healthcare system: This indicator tracks initiatives within the healthcare sector, such as COVID-19 testing protocols, emergency healthcare investments, and vaccination strategies.
Vaccination policies: These indicators record details on vaccination policies, including the country’s priority list, eligible groups for vaccination, individual vaccination costs, and the presence of a vaccination mandate.
For simplification, four main indices were created, cumulating various government measures. These indices range from 0 to 100 and seek to quantify the number and degree of measures adopted. The effectiveness of these measures is not evaluated. Since the onset of vaccination, these indices also consider how anti-pandemic measures differ between vaccinated and unvaccinated populations. The indices are defined as follows:
Overall government response index: This index tracks the evolution of the government’s response across all indicators in the database, reflecting changes in intensity during the pandemic. It is derived from all ordinal indicators.
Containment and health index: This index merges restrictions and lockdowns with measures such as testing, contact tracing policies, short-term healthcare investments, and vaccine investments. It uses all common indicators of containment, closure policies, and healthcare system policies.
Stringency index: This index measures the strictness of lockdown policies primarily affecting people’s behaviour. It includes all common containment and closure policy indicators as well as an indicator for public information campaigns.
Economic support index: This index documents measures like income support and debt policies, calculated using all common economic policy indicators.
Additionally, we considered the published numbers of confirmed COVID-19 cases and deaths [
49].
3.2. Methodology of the Study
This study aimed to create a predictive supervised model using a neural network that could accurately predict the number of vehicles of different types entering and leaving the city centre at each monitored sensor. To achieve this goal, we approached the task in this study as a data mining project, utilising the CRISP-DM methodology (Cross Industry Standard Process for Data Mining, publicly available on the CRISP-DM website [
50]). This methodology involves dividing the data mining task into six main phases outlined in the following diagram, see
Figure 5.
As we consider creating a predictive model for vehicle numbers as a data mining task, the dataset is the basic source of information for solving the task. Since this involves a large volume of automatically collected data that cannot be processed using conventional methods, we consider it big data. Subsequently, the data mining project is divided into the following six phases [
50]:
Business (problem) understanding: In this phase, we define the problem to be solved very specifically. We define the solution vision, criteria, and values the solution should meet. We try to understand the ongoing processes captured in the data.
Data understanding: In this phase, we work with the data, beginning by identifying suitable data sources, verifying the existence of appropriate data for solving the problem, and their availability. The data used in this study are described in the next section.
Data preparation: In this phase, we integrate data from various sources and databases and then proceed with their preparation until we prepare them into a modelling matrix for creating the predictive model. These processes include cleaning, validating values, calculating new variables, aggregation, filtering, and similar data operations.
Modelling: We apply machine learning methods to find the most suitable method applicable to the given data for solving the defined problem. The output of this phase is the created predictive model.
Evaluation: We check the created solution and assess its quality using evaluation statistical metrics. We verify the fulfilment of the criteria defined for the solution in the first phase.
Deployment: The final phase of the data mining project is deploying the created model into practice and implementing it into the enterprise’s internal systems or other task issuers.
To predict mobility during the COVID-19 pandemic, we used the statistical software IBM SPSS Statistics (version 26) for the data preparation phase and the data mining software IBM SPSS Modeler (version 18.3) for the modelling and evaluation phases. IBM SPSS Modeler operates on the principle of visual programming, and its significant advantage lies in its data openness. Firstly, the created modelling streams can be utilised for newly emerging or newly acquired datasets, thereby gaining new predictions. Additionally, the created models can be adapted to changed circumstances. If, over time, we find that the predictions generated by the model are no longer sufficiently accurate and do not meet the established qualitative criteria, or if the circumstances of mobility in the city have changed to the extent that it would be appropriate to capture the new situation using data in the model, the models can be updated by retraining them on new data.
3.2.1. Methodology of Data Preparation
According to the CRISP-DM methodology, preparing a high-quality modelling matrix containing data that will lead us to the solution before creating the predictive model is essential. However, it is crucial for these data to be of the highest possible quality. This means it is necessary to thoroughly check the data quality, correctness of values, relevance, and admissibility of values and to eliminate or correct any errors in the data.
It is widely known that the data preparation phase is the most time-consuming in the entire data mining project, possibly taking up more than 80% of the total project time. Similarly, in the case of this study, after a thorough examination of the data, we found errors likely caused by incorrect functioning or complete failure of communication from the sensor (or sensors). Such communication failures resulted in data errors where the sensor reported zero counts for all types of vehicles (cars, vans, trucks, and unknown) for several consecutive 15-min time intervals, and subsequently, upon the restoration of communication functionality, the sensor reported cumulative vehicles numbers for all the missing time intervals. An example is provided in
Figure 6. This specific communication failure with the sensor lasted for 76 consecutive 15-min intervals, and the diagram displays only a few zero-reported vehicle numbers. Subsequently, upon communication restoration, the sensor reported cumulative values for individual types of vehicles for all the missing time intervals, as is visible in the last displayed row.
Since using such erroneously reported values during the sensors’ failures would lead to a distortion of the predictive model being created, it was necessary to address these values in more detail. The first step involved manually identifying individual outages of all the sensors. This was not an automated task, as each case required expert evaluation to determine whether it was a failure or an acceptable value. In this way, all 72 target variables needed to be checked, and cases considered as communication failures needed to be marked.
Subsequently, after identifying failures and incorrectly reported values, we proceeded to decide on the next steps for handling these values in the analysis. One option for dealing with incorrect values is to delete them from the dataset. However, in this case, this would entail a significant loss of information as there were multiple communication failures; moreover, omitting some observations would disrupt the temporal continuity in the data. Therefore, only correcting the erroneous values, i.e., replacing them with estimated corrected values, was considered. We aimed to utilise the information we had in the rest of the dataset by using the cumulative vehicle numbers for all the time intervals during the failure. These cumulative vehicle numbers thus needed to be distributed across all the time intervals during the communication failure.
One of the options considered was replacing all zero values during the failure with the average value obtained from the cumulative numbers of vehicles. However, this solution would introduce inaccuracies into the subsequent model of mobility because, for example, if the failure lasted during both day and night hours, the zero values reported during the failure in the night hours, when vehicle numbers are naturally low and often zero, would be replaced with the average value. Moreover, the same value would be estimated during daytime hours, including peak traffic times. Therefore, we sought a more sophisticated solution for replacing incorrect values during the sensors’ failures. Finally, we opted for estimating these values by creating regression models using the information on the cumulative numbers of vehicles.
For each sensor, vehicle type, and direction, a linear regression model of the dependency of the vehicle numbers of that type on the specified explanatory variables (listed in
Table 3 above) was created. Thus, creating a total of 72 individual regression models was necessary. Each model was initially created as a full model containing all explanatory variables. Then, the final model containing only statistically significant explanatory variables and achieving the best quality was sought using the stepwise method. The quality of the regression models was evaluated using the coefficient of determination
, with values ranging from 0 to 100%. The closer the value is to 100%, the better the model captures the variability of the explained variable, making it more reliable. Associated with this is the test of the significance of the overall regression model using Analysis of Variance (ANOVA), which tests whether the model is statistically significant and whether the regression function was correctly chosen. Rejecting the null hypothesis of the model’s insignificance means that the created model is statistically significant and, thus, suitable for predictions.
The created regression models were subsequently used to predict missing values during sensor failures. Based on the values of the input variables (day of the week, time, holiday, vacation, variables related to the pandemic, etc., listed in
Table 3 above as explanatory variables) in a specific time interval, the models estimated the vehicle numbers for all the vehicle types. The estimated values were carefully reviewed, and any negative predictions were replaced with zero values.
However, it was necessary to adjust the predicted values so that their sum corresponded to the cumulative number of vehicles of the respective type reported by the sensor after the failure and communication restoration. To preserve this cumulative number, each predicted value was adjusted by an individually determined correction coefficient, calculated as the ratio of the actual to the estimated cumulative vehicle numbers during the outage. In cases where the correction coefficient could not be calculated (specifically when the estimated values were summed to zero), the missing corrected values were replaced with values corresponding to the average obtained from the cumulative vehicle numbers after the communication failure ended. All corrected values were then rounded to integer values.
To verify the accuracy of this procedure for correcting incorrect values during sensor communication failures, we calculated the accuracy of the estimates using statistical characteristics (mean, mode, median, standard deviation, maximum, minimum, and sum of values). Additionally, we quantified the deviations of the predicted corrected values from the actual values, both in absolute numbers of vehicles and as a percentage. The results for sensor 1, vehicle types, and directions are provided in
Section 4.
3.2.2. Methodology of Modelling—Artificial Neural Networks
The concept of artificial neural networks, one of the most commonly used tools in machine learning, was developed at the beginning of the 1950s, but it gained more attention from researchers only in the last decades due to a significant increase in computer technologies. The authors aimed to imitate the learning process in a biological neural network, which consists of approximately 86 billion neurons interconnected by more than 1014 synaptic connections. Neurons are designed for transmitting, processing, and storing information, with information being transmitted between neurons via electrical signals. The basic parts of a neuron are the cell body and two types of processes: dendrites and axons. Dendrites are short processes representing the signal input site into the neuron’s cell body. The place where a signal is transmitted from one neuron to another is called a synapse. In a synapse, the signal can be amplified (excitation) or weakened (inhibition) before entering the cell body. All incoming signals from surrounding neurons are aggregated in the cell body, creating the neuron’s internal potential. If this potential exceeds a certain threshold, the neuron generates an output signal, which exits the neuron through a single output process called an axon.
The so-called Hebbian rule is utilised in the learning process of artificial neural networks. Put simply, the input neuron’s activity leads to the neuron’s activity on the output side. The essence of the learning process is the formation of connections, thus creating so-called memory traces. The forgetting process is represented by the interruption of synaptic connections that could excite the neuron. In the mathematical model of an artificial neuron, this rule is reflected in synaptic weights (
w), which control the influence of input on excitation (positive weight values) or inhibition (negative weight values) of the neuron. Adjusting these weights during learning is crucial for achieving good results in artificial neural networks. The mathematical model of the most commonly used artificial neuron is depicted in the following figure (
Figure 7).
Several types of formal models of artificial neurons exist, but the most commonly used one is the perceptron, designed by Frank Rosenblatt in 1958 [
53,
54]. The essence of the perceptron is the computation of the artificial neuron’s internal potential, which is given as the weighted sum of inputs. This potential is further processed by an activation function, typically one of the S-shaped curves. The most commonly used is a sigmoid function, given by the following equation:
However, the perceptron can only be used to solve linearly separable problems. The solution involves using multiple perceptrons arranged into several layers for more complex tasks. The learning process then takes place in the so-called hidden layers. Thus, the network contains one or more layers of neurons that are neither input nor output. Multi-layer perceptron networks (MLPs) are the most widely used type of artificial neural networks in predictive analysis. These networks can tackle more complex problems by utilising each hidden layer to extract features and recognise patterns, enabling them to effectively perform intricate classification or regression tasks.
MLP networks are, therefore, suitable for solving any problem whose essence is predicting the values of the modelled (output) variable. However, it is important to set or search for the correct topology of this network. Specifically, this involves setting the number of hidden (computational) layers and the (maximum) number of neurons in them, as well as choosing a suitable activation function, which can be the sigmoid mentioned above but also other functions such as the hyperbolic tangent or the ReLU function. The goal is effective learning of the neural network on the training dataset, especially its good generalisation ability, i.e., its use of data outside the training dataset. A common problem with MLP neural networks is overfitting, or “over-adaptation to the data” from the training dataset. This problem is typical for most machine learning tools.
To eliminate the problem of overfitting, the dataset is divided into a training and testing part. The data cases from the training set are used to validate the predictive ability of the neural network. The remaining data cases (training set) are presented to the neural network as learning patterns. The network learns to create connections between neurons on these patterns so that its response, i.e., outcomes, closely approximates the actual or desired outcome. The neural network must then be able to generate responses based on the acquired knowledge for cases that were not a part of the learning process. And this is precisely the generalisation ability verified on the validation (testing) set. The training process ends if the resulting prediction error is approximately the same and sufficient for both sets. However, suppose the prediction error on the validation set is significantly lower and/or insufficient. In that case, another iteration (epoch) of learning follows, using the knowledge gained in the previous epochs to adjust the network (especially synaptic weights). This iterative learning process ends when the network achieves the desired generalisation ability on the validation set. The gradient descent method was used to find synaptic weights, minimising the error function (prediction error) at each step of the solution search. Finding the global minimum of the error function using this iterative method significantly depends on the so-called learning rate . With relatively large values of this parameter, we risk “skipping” the sought global minimum, and on the other hand, with small values of this parameter, we risk slow convergence to this minimum. Therefore, the optimal value of this coefficient is also determined in individual steps of neural network learning.
Finally, the model is deployed on the testing set, i.e., on cases not used in the learning process, and the resulting predictive evaluation metrics are determined.
Neural network models generated predictions for the number of vehicles across all cases in the dataset, including those in the testing subset. Predictions for the testing data were produced using a model that had not been trained on them, allowing for an independent evaluation of the model’s quality by comparing these predictions with actual outcomes. Consequently, this study presents the model quality assessment results exclusively for the testing data. With sufficient cases in the dataset, the division into training and testing subsets was done randomly at a 50:50 ratio.
The models in this study were developed as ensemble models using neural networks. Ensemble models typically fall into two categories: bagged and boosted. Boosting entails training a series of models sequentially, where each subsequent model is trained to correct the errors of the previous one. Bagging, on the other hand, involves training multiple models independently on different subsets of the training data, with their individual predictions aggregated. Combining the predictions from these model sequences generates a final prediction that is more accurate and robust than the predictions of any single model.
Combining individual models into a composite model can be achieved through several methods. The most commonly used techniques include:
Stacking: This method involves training multiple models and then using a meta-model to combine their predictions. The meta-model uses the predictions from each base model as explanatory variables to generate the final prediction.
Competition: In this approach, the prediction with the highest reliability (confidence) is selected from the individual predictions of each model for each case in the data.
Voting: This method combines individual models by averaging their predictions.
Weighted voting: Similar to voting, this approach averages predictions from each model but assigns weights to them based on a specific metric, such as reliability.
Combining models is an effective technique for enhancing the accuracy and robustness of predictive models. By leveraging the strengths of multiple models, composite models often outperform individual models, providing more reliable predictions.
In this study, we used the boosting method to create an ensemble model to enhance the models’ accuracy. Specifically, for each type of vehicle, we developed an ensemble model composed of several neural network component models. Each ensemble’s maximum number of these component models was set to 10. Each component model was built using a multi-layer perceptron (MLP) neural network. The number of hidden layers and the size of each MLP component model (i.e., the number of synapses) were determined automatically by the software. After creating the component models, the final ensemble model was formed by combining them through a voting technique that averaged their predictions. Using this methodology, we created eight ensemble models—one for each type of vehicle and one of both directions—and an additional model that combined all vehicle types and directions, each containing up to ten component models.
Due to the computational complexity involved in manually designing and fine-tuning the neural network models, we opted for the automatic creation of the models. This decision was made to optimise the process and avoid the complexities and potential biases associated with manually selecting the number of neurons. Manually building each model would have had an unwanted level of error in determining the optimal architecture, including the number of layers, nodes, and connections, and would have been extremely time-consuming. It was more important to obtain accurate predictions from the model. By relying on automatic model creation, we ensured a more efficient and systematic approach to generating well-optimised models, allowing us to focus on the analysis and interpretation of results rather than on the intricate details of model configuration. This approach also provided a consistent and unbiased method for determining the best-performing model architecture across different vehicle types and directions.
For all statistical tests in this study, a significance level of 0.05 was used. Therefore, even if not directly mentioned, the tests’ conclusions were always formulated using this significance level.
3.2.3. Methodology of Model Evaluation
After creating neural network models, evaluating the quality of the obtained predictions is important. Current machine learning models are very sophisticated and capable of memorising input data perfectly, leading to overestimated evaluation statistics obtained from such models because predictions are checked on the same data on which the model was created. To verify the model’s true predictive power, we randomly divided the dataset into training and testing sets. The second part of the data, the testing set, is used for model validation. Predictions (estimated numbers of vehicles of various types) are made on these testing cases in data and then compared to the actual values of the vehicle numbers. Since the model did not know the testing data, it was not trained on them; this comparison can be considered as the true predictive ability of the model without overestimation [
55,
56].
The predictive ability of the model can be evaluated using several evaluation statistics [
56]:
Minimum error, maximum error, and mean error, which means a comparison of the predicted and actual vehicle numbers;
Mean absolute error, calculated from the absolute differences between predicted and actual vehicle numbers;
The standard deviation of the differences between predicted and actual values of vehicle numbers;
Linear correlation is a coefficient expressing the strength of linear dependence between predictions and reality.
When comparing the accuracy of models, it is advisable to focus on one of these evaluation statistics. The most commonly used are mean absolute error (which should be as small as possible) and the correlation coefficient (the closer the value is to 1, the more accurate predictions the model generates). In this study, we mainly used the correlation coefficient to evaluate the models, although, in the Results section, we provide all the mentioned evaluation statistics of the created partial models for individual types of vehicles and their directions and the comprehensive model for all types and directions.
Finally, the precision of the predictions made by the neural network ensemble models is compared with that of four models created using other data mining techniques. For this purpose, we chose two decision trees: CART (Classification and Regression Tree) and CHAID (Chi-square Automatic Interaction Detection), as well as the Nearest Neighbours method and Multivariate Linear Regression. To ensure comparability of model performance, all these comparative models were also created as ensembles, following a similar procedure to that used for the neural network models, with up to ten component models combined by averaging their predictions into a final meta-model. After the learning procedure, the predictions for the cases in the training sample were compared with the actual values of the number of vehicles of individual types. Finally, the performance of these models was evaluated using the correlation coefficient mentioned above.
For brevity, we do not provide a detailed explanation of the methodology used for the four comparative models here, but it can be found, for example, in [
55,
57,
58,
59].
4. Results
4.1. Results of Data Preparation
In the Methodology of Data Preparation section, we emphasised the importance of thorough verification and adjustment of vehicle numbers reported by sensors, especially in the case of inaccurately reported values during sensor failures. For this purpose, we developed individual regression models that helped us correct erroneous values. These were further adjusted to ensure the consistency of cumulative vehicle counts after the sensor connection interruption was resolved. Additionally, we had to address some unacceptably high values, which were corrected by replacing them with values predicted from linear regression models.
Table 4 presents the results of corrections compared to the actual values for sensor 1. The main statistical characteristics of the actual and corrected values for all four types of vehicles and both directions are provided. At the end of the table, the absolute and relative differences between the actual vehicle numbers and the numbers corrected by the proposed method are quantified.
The last three rows in each sensor’s table (both for in and out directions) demonstrate that the proposed procedure for correcting values during sensor communication failures accurately replaced the error values. The percentage errors of these corrections, caused by rounding the estimated vehicle numbers to integer values, are quantified in the last row of the table. Some sensors (e.g., sensor 6 in the direction “in” or sensor 9) exhibit higher correction errors because, apart from failures, these sensors also had erroneously reported values that were not caused by communication failures. These erroneous values manifested as reporting an unreasonably high number of vehicles in a given 15-min interval. Since the source of this error could not be identified, these values were only replaced with predicted values from the created regression models, and they could not be corrected using the correction procedure mentioned above, as the correct value is unknown. This resulted in a higher error in the sum of corrected values compared to the total actual number of vehicles of a particular type for the entire observation period.
The data, adjusted in this way and prepared into the final form of the modelling matrix, can also be described using a graphical representation. The number of vehicles of different types in the direction toward the city centre (direction “in”) is illustrated in the following histogram (
Figure 8). The histogram depicts the course of vehicle numbers during the day, where the height of each bar represents the average number of vehicles of a specific type at a particular time of the day. The graph shows the overall average (total height of the bar) regardless of the sensor, and the individual sensors are colour-coded, with the height of the bars in each indicating the average number of vehicles of a specific type at a given time on a specific sensor.
Figure 9 illustrates the vehicle numbers in the direction from the city centre (direction
out), colour-coded according to the individual sensors.
The total number of vehicles in the inward and outward directions is depicted using boxplots in
Figure 10. The boxplots are differentiated by individual sensors and represent statistical characteristics: the inner line in the box is the median vehicle number, and the upper and lower edges of the box are the upper and lower quartiles of the vehicle number. Additionally, the boxplot highlights outliers (circles) and extreme values (crosses), which are vehicle numbers that differ from the typical numbers. These correspond to traffic peaks and can indicate which sensors typically record such high vehicle numbers.
The following figures describe the relationships between selected two COVID-19 pandemic-related variables and the number of vehicles.
Figure 11 depicts the boxplots showing the relationship between school closing and the number of vehicles of different types. On the left side are the boxplots for direction in, and on the right side the direction out. The scale of the vertical axis has been adjusted for better visibility of the range of values; therefore, not all values marked as outliers are visible.
The exact values of statistical characteristics shown in
Figure 11 are listed in
Table 5. The median values show that the level of school closing measures impacted the number of vehicles.
A similar dependence is depicted in
Figure 12 for the numbers of vehicles and workspace closures measure levels.
The exact values of characteristics shown in
Table 6 present the various numbers of vehicles for individual levels of the measure. The differences can be seen mainly in the values of medians.
4.2. Results of Modelling
As mentioned earlier, the mobility model during the COVID-19 pandemic period was created using the neural network. We constructed the modelling stream in the IBM SPSS Modeler software, presented in
Figure 13.
Each “yellow diamond” in the figure represents one neural network model for a given type of vehicle. Additionally, on the left side, there is a comprehensive model containing all types of vehicles and both directions. The models are not constructed separately for individual sensors but include the sensor as one of the explanatory variables.
Since a neural network model is generally considered a “black box”, it is impossible to precisely interpret the model results in terms of relationships between input data, neural network layers, and the model’s output in the form of predictions. It would be possible to describe the strength of the relationship, but there are many such relationships in a neural network, leading to a loss of clarity in interpreting the results. An example of a neural network model is shown in
Figure 14, representing a model for cars entering the city centre (cars_in).
Therefore, instead of interpreting each relationship, we focused on the importance of predictors (explanatory variables) in the created models [
39,
60]. This information is crucial for demonstrating the pandemic’s impact and implementing anti-pandemic measures on city mobility. In each neural network model, it is possible to illustrate the importance of predictors along with their significance in the model.
Figure 15 shows the predictor importance for the comprehensive mobility model. The model includes other explanatory variables apart from those depicted, but for the figure, we have only included those that are significant in the model at the chosen significance level. The importance is calculated so that the cumulative importance of all the explanatory variables used in the model is one.
Among the most important variables (in the order of importance) in the model are the following:
Sensor number (variable name sensor) was used as one of the explanatory variables to avoid creating a model for each sensor separately; this variable has the highest importance in the model.
Month of the year (variable name month); its presence among the important variables suggests changes in mobility throughout the year.
Day of the week (variable name day of the week); its presence suggests changes in mobility throughout the week.
Time (variable name time) divided into 15-min intervals during the day; the presence of this variable in the model confirms that vehicle numbers vary significantly throughout the day.
Number of confirmed deaths during the COVID-19 pandemic (variable name confirmed deaths), cancellation of public events during the pandemic (variable name cancel public events), number of confirmed cases (variable name confirmed cases), containment health index during the pandemic (variable name containment health index), and restrictions on gatherings during the pandemic (variable name restrictions on gatherings).
The presence of the variables mentioned above related to the COVID-19 pandemic in the model demonstrates the significant impact of the pandemic and the implemented anti-pandemic measures on vehicle numbers in the city. The neural network model created in this way, with the automatic selection of variables with the greatest impact on vehicle numbers, has shown that mobility was significantly influenced by the course of the pandemic and the level of implemented measures. There are still other variables in the model, but they are not of such importance, so they are not included in the previous figure.
We also created individual neural network models for each type and direction of the vehicle. These models achieve high prediction accuracy as they were developed using the boosting method, which aims to increase the model’s predictive ability. Each of these boosted models is composed of up to ten models, where each subsequent model aims mainly at the incorrectly predicted cases of the previous model, striving to improve predictions for them.
The difference between the comprehensive model presented in
Figure 11 and the partial models for individual directions and types of vehicles lies in the fact that the partial models are additionally created using boosting, resulting in more accurate predictions. Using this method for the comprehensive model is impossible because it cannot handle multiple dependent variables.
These individual models are also difficult to describe or illustrate with figures because each is an ensemble model from a series of models. However, each of these boosted models generates predictions for the number of vehicles of a specific type, which are more accurate due to the complexity of the model. An example of a composite model for predicting the number of cars_in is shown in
Figure 16.
After creating the models, we further ensured the validity of the generated predicted values. Since no boundary conditions are specified during model creation, the model can generate values of the dependent variable within the interval of real numbers. However, from a substantive point of view, negative predicted values are unacceptable. Therefore, we recoded all negative predicted values to zero, enhancing the accuracy of predictions. On the other hand, allowing excessively high predicted values for the number of vehicles is not suitable. Therefore, we set the maximum permissible value to 300, which was also used as the maximum allowable value during the data preparation phase.
4.3. Model Evaluation
As mentioned in the study’s methodological part, the data were randomly divided into training and testing sets to avoid overestimation. The above-described models were created on the training data, while the resting testing data were used for model evaluation. In
Table 7, we present the evaluation characteristics of the created models on the testing part of the data. We also supplemented the table with statistical characteristics of the actual number of vehicles in the testing part of the data and the corresponding predicted number. By comparing the rows on the left side of the table, we can claim that the predictions, on average, correspond to the real numbers of vehicles.
Figure 17 presents the graphical evaluation of the predictions from individual models for vehicle types. Each scatter-dot graph presents the dependence of predictions and the real values. The values close to the diagonal (yellow line) mean the model’s high performance.
If we evaluate the accuracy of predictions using the correlation between predicted and actual vehicle numbers, we can say that the created neural network models generate very accurate predictions. The lowest correlation is in the individual models, with 0.73 for trucks_in, and in the comprehensive model, with 0.69 for trucks_in. This lower predictive accuracy of the model is due to the low variability of truck numbers of this type, which range from 0 to 26 vehicles every 15 min. The best-performing models are for predicting cars (cars_in and cars_out) and vans (vans_in and vans_out), where the correlation ranges from 0.92 to 0.93 in individual models and from 0.89 to 0.91 in the comprehensive model. Therefore, predictions generated by these neural network models are considered very accurate, as the dependency between estimated and actual numbers of vehicles of a given type is very strong.
4.4. Comparison with Other Methods
In this section, we compare the results of predicting the number of vehicles using ensemble neural network models with those generated by models created using different techniques. As mentioned in the methodology section, we employed four methods suitable for solving regression data mining tasks: decision trees of the CART and CHAID types, nearest neighbours, and multivariate linear regression. To ensure comparability with the ensemble neural networks, all these models were created also as ensembles, containing up to ten component models. The predictions of these models for the testing data were compared with the actual values, and their performance was evaluated using correlation coefficients.
Table 8 presents a comparison of these models with the neural network models. The nearest neighbour technique did not provide a solution for some types of vehicles due to the data dimensionality and the memory demand on computations (denoted as “NA” in the table). The correlations of actual and predicted values show the ensemble neural network models’ high performance compared to the other used methods.
5. Discussion
As we mentioned in the Literature review section, neural networks are widely used machine learning techniques for modelling traffic and predicting the number of vehicles. In this study, we also created a functional model for the traffic in the city of Zilina in Slovakia, considering the situation during the COVID-19 pandemic. The impact of the pandemic on the number of vehicles was described by using the respective variables publicly available for each country. Therefore, the methodology described in this study applies to any other city worldwide. Thus, the study’s contribution lies in the ease of updating the created neural network models using newly emerging data, thereby adapting mobility prediction to any changes in the situation after the pandemic ends or the circumstances in any other city. This opens up the possibility of further research, where the actual impact of the pandemic on mobility in the city can be quantified by comparing data from the pandemic and post-pandemic periods.
As a strength of this study, we consider the fact that predictive models of mobility in the city of Zilina during the COVID-19 pandemic were created based on real data from sensors installed at intersections in the city, providing real information about vehicle numbers moving in the city. This dataset covers a sufficiently long period of the year, allowing us to capture changes in mobility not only throughout the day but also across different periods of the year. These data were thoroughly checked, and all errors were identified and corrected. The erroneous data were corrected using a sophisticated statistical approach through regression modelling to preserve the most accurate information about mobility in the city.
Another strength of the study is the use of modern machine learning methods, which achieve high accuracy in their predictions. Moreover, the models were created using the boosting method to enhance their predictive ability. The study not only describes the predictions obtained by the model but also interprets the impacts of the most important input variables used for mobility modelling. This demonstrated the impact of the pandemic and the implemented anti-pandemic measures on mobility in the city.
However, this study also has its weaknesses. One can be identified that the COVID-19 pandemic is quantified using variables that are admittedly internationally recognised and published for all countries worldwide for comparability purposes. However, on the other hand, they capture the nationwide situation. They are not region-specific, which introduces a certain bias in modelling their relationship with the vehicle numbers in the city. It would be more precise to use variables that accurately reflect the situation during the pandemic, specifically in the individual city. However, mainly due to the unavailability of such data, we opted to use these variables.
Another limitation of the study is the inability to compare traffic patterns with the pre-pandemic period up to 2019. Data from this period are not available because the WSN was not yet installed at that time. The entire network, along with the publicly accessible interface, was developed as part of the INTERREG V-A SK-CZ/2019/11 project CLEVERNET—“Deploying innovative sensor networks in cross-border regions”. The main activities of the project commenced in January 2021. Over time, it will be possible to analyse data without the impact of the pandemic, and increasingly accurate data will be available as the network is constantly troubleshooting and calibrating sensors. Further analysis and applications for using such a network will be the subject of future studies.
The data from the sensors is still publicly available; it can be viewed, compared, and downloaded practically without restrictions in a user-friendly environment. However, the truth is that in practice, it still has no other function than a presentational—informational one. However, while the current usage of the sensor data is limited to informational and presentational purposes, there is significant potential for its future application. For example, city planners and policymakers could use the data to make informed decisions about traffic management, public transportation improvements, and infrastructure development. The data could also be valuable for researchers studying urban mobility patterns, environmental impacts, and smart city technologies.
Furthermore, businesses and entrepreneurs might find innovative ways to leverage the data to create or enhance existing services. For instance, companies involved in logistics and transportation could optimise their routes and operations based on real-time traffic information. Similarly, startups could develop applications that provide residents and visitors with up-to-date information on traffic conditions, helping them to choose the most efficient travel routes.
Apart from the mentioned usage of the publicly available data from the sensors, we can mention that the usability of data from the sensors is very wide and understanding the inputs and outputs of traffic flow values provides several significant benefits that can enhance various aspects of traffic management, optimisation of road networks and intersections and planning new roadways, expanding existing ones, and designing effective traffic management strategies or optimising public transportation routes and schedules.
Moreover, analysing traffic flow data helps optimise traffic signal timings at intersections. By understanding traffic patterns and congestion levels, traffic signals can be adjusted to improve vehicle throughput, reduce delays, and enhance overall traffic flow. Data-driven insights enable the implementation of adaptive traffic signal systems that adjust signal timings in real-time based on current traffic conditions, leading to more efficient traffic management.
From the macroscopic point of view, traffic flow values are used to create and refine models that simulate overall traffic patterns and congestion in a city. These models help in understanding traffic dynamics and in planning infrastructure improvements. On the other hand, from the microscopic point of view, detailed traffic flow data supports models that simulate individual vehicle interactions and movements. These models are useful for studying the effects of specific roadway changes or traffic management strategies.
Finally, real-time traffic flow data help in detecting incidents such as accidents or road closures. This allows for timely responses and implementation of alternative routing strategies to minimise disruption.
In summary, the benefits of analysing traffic flow values are extensive and impact various facets of traffic management, urban planning, and transportation efficiency. By leveraging these insights, cities can enhance their traffic systems, improve safety, and provide better services to residents and travellers.
In summary, while the immediate application of the sensor data in the city of Zilina may be limited, its potential for future use is vast. Continued investment in data quality, user interface improvements, and community engagement will be essential in unlocking the full benefits of this valuable resource.
6. Conclusions
The aim of this study was to create a model of mobility able to predict the vehicle numbers at intersections in the city of Zilina during the COVID-19 pandemic using artificial intelligence methods (machine learning). The method of neural networks was employed to build this model, whose main advantage is its high prediction accuracy. In this study, we achieved correlations between the prediction results and actual values ranging from approximately 0.70 to 0.95 for individual sensors and types of vehicles. In interpreting the study results, we focus not only on the predictions but also on interpreting how the pandemic affected mobility in the city. By examining the importance of individual variables in the created model, we found that the pandemic, quantified using internationally acknowledged variables describing its status and governmental responses in the form of implemented anti-pandemic measures, significantly impacted vehicle numbers in the city.
Individual types of vehicles, directions, and sensors are predicted separately, capturing the overall mobility in the city. By aggregating the predicted vehicle numbers, the total vehicle numbers can be easily obtained regardless of their type or the sensor through which they pass. Moreover, since the task was approached using a data-mining approach and the models were created using data-mining software IBM SPSS Modeler, the created solution is easy to update. The model captures mobility in the city during the pandemic but is easily adaptable and updatable, which we consider its significant advantage. The model is data-open and can make new predictions after importing new data.
Additionally, with new data, the model can be easily retrained to predict the number of vehicles under normal circumstances in a situation without a pandemic. This will subsequently enable quantifying the impact of the pandemic ex-post. Finally, the model should be easily adapted for predicting mobility in any other city, as it can be retrained on a new training sample containing the variables describing mobility circumstances specific to that city.