Next Article in Journal
Survivability of Probiotic Microflora in Fermented and Non-Fermented Mare’s Milk: A Comparative Study
Previous Article in Journal
Occurrence of Fungi on Duck Egg Shells and Drug Resistance Analysis of Aspergillus spp. Isolates
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

The Use of Machine Learning Methods in Road Safety Research in Poland

1
Faculty of Security, Logistics and Management, Military University of Technology, 00-908 Warsaw, Poland
2
Doctoral School, Military University of Technology, 00-908 Warsaw, Poland
*
Author to whom correspondence should be addressed.
Appl. Sci. 2025, 15(2), 861; https://doi.org/10.3390/app15020861
Submission received: 17 December 2024 / Revised: 12 January 2025 / Accepted: 15 January 2025 / Published: 16 January 2025

Abstract

:
Every year, thousands of accidents occur in Poland, often resulting in severe injuries or even death. The implementation of solutions supporting road safety analysis and management processes is necessary to reduce the risk of accidents and minimize their consequences. One of the rapidly developing tools that can play a key role in this area is machine learning. The aim of this study was to develop mathematical models based on ML algorithms describing road safety in Poland. First, variables with the strongest impact on safety were extracted. Then, mathematical modeling was performed using the k-Nearest Neighbors, Random Forest, and RPart algorithms. The best choice for imbalanced data, especially when the goal is to identify rare classes, is the RF model. The KNN model provides a compromise in situations where the highest overall accuracy is desired. On the other hand, the RPart model can be used as a fast, basic model, but it requires improvements to handle rare classes. The results not only identified factors that significantly affect the severity of injuries or the number of fatalities in accidents but, above all, also demonstrated the ability of ML-based models to predict threats and their consequences.

1. Introduction

Road safety is one of the most critical challenges facing modern society, significantly impacting public health, the economy, and the overall quality of life [1]. Each year in Poland, thousands of traffic incidents result in fatalities and severe injuries among road users. Reports from the Polish National Police Headquarters and other safety analysis institutions indicate that despite preventive measures, the number of such incidents remains alarmingly high [2,3]. In this context, implementing advanced solutions to enhance the road safety analysis and management process is essential [4]. One of the most rapidly evolving technological tools in this domain is machine learning (ML), which can play a pivotal role. ML enables the analysis of large and complex datasets that traditional methods often struggle to process efficiently [5,6]. In the context of road safety, ML can identify patterns and correlations between factors contributing to traffic incidents and even predict potential risks and their consequences, such as injuries or fatalities. Globally, ML applications in road safety include developing intelligent traffic management systems, identifying high-risk road segments, analyzing driver behavior, and forecasting infrastructure failures [7,8,9].
In Poland, the use of ML in road safety is particularly relevant due to the rapid expansion of the transportation network and ongoing urbanization [10,11]. Additionally, the structure of Poland’s road network, dominated by local roads where the risk of incidents is significantly higher than on expressways, underscores the importance of innovative approaches [12]. Currently, most road safety research in Poland focuses on the causes of road incidents and their consequences for participants [13,14]. The authors of these publications conduct analyses of the injured and casualties by year, while making comparisons against other EU Member States and pointing out changing trends [15,16,17]. The causes of collisions and accidents in road traffic are equally often addressed [18]. The relationship between weather conditions and the number of incidents is mainly analyzed [19,20]. Other studies emphasize that in addition to the weather, driver behavior and traffic volume, which determines, among other things, the increase in the total number of vehicles on the road, have an impact on the increase in incidents [21]. In addition, the number of accidents has been shown to depend on the time of day [22]. Due to the multitude of factors that determine the occurrence of accidents in Poland, a methodology for optimizing them is proposed [23]. Publications often point out potential solutions and areas for improvement to enhance the safety of road users [24,25]. Advanced Driver Assistance Systems (ADAS) and the development of autonomous technologies are frequently highlighted as promising approaches to reducing collisions and accidents [26,27]. An extremely popular issue in recent years has been the “Vision Zero” strategy of using all the available methods and means to almost completely minimize injuries and casualties [28]. It is pointed out that complementary to the achievement of this goal can be road infrastructure development, legislative action by the authorities, international cooperation, and the implementation of innovative technologies in vehicles, among others [29,30].
Mathematical modeling is a widely used tool in road safety research, particularly for evaluating current safety levels and developing effective solutions [31,32]. It is also applied to assess the reliability of transportation systems [33,34,35]. Recently, the significance of machine learning (ML) tools in this area has grown substantially, as evidenced by numerous applications [36]. However, fully harnessing the potential of ML algorithms requires a unified system for collecting and sharing data on road incidents and traffic volumes [37]. Establishing such a system should be a priority for policymakers aiming to improve road safety. ML can be used to estimate the probability of traffic incidents, as well as to assess risks in specific locations and conditions [38,39]. Predictions are typically based on historical data, such as collision or accident counts, participant injury levels, weather conditions, and traffic volumes [40]. These analyses are crucial for identifying high-risk areas, including hazardous road segments [41,42]. This insight is invaluable for guiding preventive measures, such as redesigning infrastructure to improve safety. Another ML application in road safety involves systems equipped with cameras and sensors that automatically detect incidents, such as vehicle breakdowns, congestions, collisions, or infrastructure damage [43,44]. By integrating ML algorithms, these systems can process large datasets efficiently, enabling faster responses to road incidents and, ultimately, improving safety outcomes [45]. ML is also employed to monitor and analyze driver behaviors, including acceleration, braking, and reactions to obstacles [46]. Algorithms can identify risky behavior patterns, such as driving while fatigued or distracted [47], which supports the continuous development of Advanced Driver Assistance Systems (ADAS) [48]. ML also plays a vital role in optimizing traffic flow, reducing the risk of collisions and accidents caused by congestion, sudden stops, or uneven traffic distribution [49]. Studies highlight the importance of ML in alleviating congestion, dynamically managing traffic signals, and even planning detours when routes become impassable [50,51]. Research also demonstrates the potential of ML to predict the need for transport infrastructure repairs by analyzing data on its condition and environmental factors [9,52]. This approach not only aids in making informed decisions about road and structural maintenance investments but also reduces the risk of traffic incidents caused by poor road conditions or excessive wear to infrastructure, such as bridge structures [53,54].
However, less attention has been paid in the literature to developing mathematical models based on ML algorithms that identify traffic incidents in Poland and predict their consequences for participants. This gap has become the focus of this article. This publication aims to develop mathematical models based on ML algorithms to describe road safety in Poland. This study is based on two key research questions:
  • What factors significantly impact road safety in Poland?
  • How effective and efficient are classification models based on ML algorithms in describing road safety in Poland?
To address these questions, this study first selected the most influential variables to reduce the data dimensionality and model size. This was followed by mathematical modeling of road safety in Poland using selected machine learning algorithms. The results not only identified factors that significantly affect the severity of injuries or the number of fatalities in accidents but, above all, also demonstrated the ability of ML-based mathematical models to predict threats and their consequences.
This article is structured into several sections. The introduction presents a general outline of this study and provides a literature review, highlighting publications that examine the causes and consequences of road incidents and propose solutions to mitigate them. This section also outlines potential applications of ML in road safety research. The second section describes the materials used and the methods applied in this study. In the third section, the variables with the strongest impact on road safety are extracted and analyzed in detail. The fourth section focuses on mathematical modeling using selected ML algorithms and evaluates the quality of the proposed models. Then, the results obtained using all the considered models are discussed. Finally, this paper presents its conclusions, taking into account the limitations and directions of future research.

2. Materials and Methods

In Poland, information on traffic incidents is collected by the police in the System of Accident and Collision Records (SEWiK). This study was based on road accident databases from 2019 to 2023 [2].
This paper examined the influence of selected factors on road safety, specifically focusing on the severity of injuries sustained by participants and the number of fatalities in accidents. The first step involved selecting the most significant variables to reduce the data dimensionality and model size. The Random Forest (RF) method was employed for this purpose. Based on the mean decrease Gini index [55,56], 11 variables with the strongest impact were identified and then analyzed in detail. This was followed by mathematical modeling of road safety in Poland using the machine learning algorithms listed below.

2.1. K-Nearest Neighbors (KNN) Algorithm

K-Nearest Neighbors (KNN) is a supervised machine learning algorithm widely applied in regression and classification problems across datasets of varying sizes, ranges, and contexts [57]. KNN is one of the simplest ML algorithms, characterized by its adaptive and easy-to-understand structure. This is a method that relies heavily on similarity analysis between observations in the feature space. The KNN algorithm is able to classify datasets using a training model similar to the test query, considering the k-nearest training data points (neighbors) closest to the query. The final classification is determined using a plurality vote of its neighbors [58]. The parameter k (the number of neighbors) significantly influences the model’s performance. While the Euclidean distance is most commonly used for the calculations, other metrics, such as Manhattan distance, can also be applied [59].

2.2. Random Forest (RF) Classification with Cross-Validation Algorithm

Random Forest (RF) is an ensemble-learning-based machine learning method used for both classification and regression problems [60]. In the case studied, a classification model was used. It is a random-forest-based algorithm that constructs a “forest” of multiple decision trees, making it more resistant to overfitting compared to single decision trees. RF generates independent decision trees based on random subsets of training data, and the final classification result is determined by plurality vote (the most frequently chosen class) [61]. In this study, the Random Forest method was combined with cross-validation to obtain a more accurate model evaluation. Cross-validation divides the data into K folds. The model is trained on K − 1 folds and tested on the remaining one. This process is repeated for each fold, and the final result is the average of the performance metrics obtained. Cross-validation provides a more reliable model evaluation, avoiding the randomness associated with a single train–test data split [62,63].

2.3. RPart Classification with Cross-Validation Algorithm

Recursive Partitioning and Regression Trees (RPart) is an algorithm that belongs to the class of decision-making algorithms and is based on the classification and regression trees (CART) method [64,65]. It is used for classification and regression by dividing data into smaller, more homogeneous groups (partitions) with respect to the target variable (class for classification). RPart, like other decision trees, splits the dataset into subsets based on the input features to achieve the highest possible homogeneity of explanatory variables in relation to the dependent variable within each resulting group (tree nodes) [66]. In this study, cross-validation was also applied to the RPart algorithm to improve the accuracy and reliability of the model’s performance, following a similar methodology as with Random Forest [67].

2.4. Evaluation of the Quality of the Classification Models

Various metrics are used to evaluate classifiers. Typically, these metrics are derived from the confusion matrix, which evaluates the effectiveness of classification models in making predictions based on test data and indicates the performance of the classification model. This matrix can be used to compute various parameters of the model, such as the accuracy, precision, and sensitivity, and to plot the AUC-ROC curve [68]. A simplified confusion matrix with calculations of the basic metrics is shown in Figure 1 [69].
The rows of this matrix represent the correct decision classes, while the columns represent the decisions predicted by the model. The value Nij at the intersection of row i and column j determines the number of observations of class i classified into class j, 1 i , j h . In a general context, it takes the form presented in Table 1.
For each class, we estimated the basic values: TP (true positive)–number of outcomes (instances) correctly classified as belonging to a particular class, FP (false positive)–number of outcomes incorrectly classified as belonging to a particular class, FN (false negative)–number of outcomes incorrectly classified as not belonging to a particular class, TN (true negative)–number of outcomes correctly classified as not belonging to a particular class. According to the notation presented in Table 1 for the j-th class (1 ≤ jh), the basic values were determined as follows:
T P = N j j ,
F P = i = 1 , i j h N j i ,
F N = i = 1 , i j h N j i ,
T N = i , j = 1 h N i j T P F P F N .
Additionally, for each class, we estimate the following basic metrics [70]:
  • Sensitivity (recall, true positive rate–TPR), indicating the extent to which a true positive class was classified as positive:
T P R = T P T P + F N
  • Specificity (true negative rate–TNR), indicating the extent to which a true negative class was classified as negative:
T N R = T N T N + F P
  • Positive predictive value (PPV), indicating the confidence in positive predictions, i.e., the percentage of positive predictions confirmed as true positives:
P P V = T P T P + F P
  • Negative predictive value (NPV), indicating the confidence in negative predictions, i.e., the percentage of negative predictions confirmed as true negatives:
N P V = T N T N + F N
  • Balanced accuracy is an arithmetic average of sensitivity and specificity, and it determines the average number of predictions for each class correctly classified by the model (particularly useful when there is only one test set and it is not balanced):
B a l a n c e d   A c c u r a c y = T P R + T N R 2   .
For the entire classifier, we determined the accuracy (ACC), which denotes the fraction of all instances that are correctly categorized [71]:
A C C = i = 1 h N i i i , j = 1 h N i j
Additionally, Cohen’s Kappa statistic was used to evaluate the classifiers. This metric is more informative than the accuracy when working with imbalanced data [72]. The Kappa is a measure of how closely instances classified by a machine learning classifier match the data labeled as ground truth, controlling for the accuracy of a random classifier as measured by the expected accuracy. The value of the Cohen’s Kappa metric ranges from −1 to 1 [73]. This statistic is described by the following equation:
K a p p a = 1 1 p o 1 p e   ,
where po is the observed agreement and pe is the expected agreement [74].
Moreover, the non-parametric McNemar test was used to statistically compare the accuracy of the selected classifiers in this research. The chi-square value (χ2) was calculated as follows:
χ 2 = ( F N F P 1 ) 2 ( F N + F P )   ,
where FN is the false negative and FP is the false positive [75].
Within the scope of this study, modeling was carried out using R Core software (version 4.4.2), along with packages that provide a set of machine learning and pre-processing algorithms [76].

3. Analysis of Variables Describing Road Safety

3.1. The Selection of Variables for the Models

Road safety is influenced by a wide range of factors that can contribute to hazardous events, often resulting in injuries or even fatalities among participants. The primary goal of this stage of the present study was to identify the variables with the most impact on road safety and select them for further analysis. To reduce the data dimensionality, a Random Forest model was employed to predict the variable representing the classification of injury severity. The model utilized 500 trees, and four variables were randomly selected at each split. The out-of-bag (OOB) error was 32.99%. This indicates that the model has difficulty in accurately predicting classes, especially for more complex categories, as shown by the confusion matrix (Table 2).
Based on the example of the category “no injuries”, the values of the individual classification errors shown in Table 2 were calculated according to the following algorithm:
C l a s s .   e r r o r = 1 N 11 j = 1 4 N 1 j × 100 % ,
C l a s s .   e r r o r = 1 21,546 21,546 + 1811 + 106 + 13 × 100 % = 8.22 %   .
The model performs best with the “no injuries” category, achieving a low classification error rate of 8.22%. However, the results are less accurate for more severe categories of injuries. For the “minor injuries” category, the accuracy is moderate, with an error rate of 31.25%. In contrast, the error rates for the “severe injuries” and “deaths” categories are significantly higher, at 89.13% and 92.70%, respectively. The variables used in the model were ranked based on their mean decrease Gini values, as presented in Table 3.
Nevertheless, the purpose of this stage of the present study was to extract the variables with the strongest impact, which are included later in this study (Section 4). A total of 11 predictors were selected, as illustrated in Figure 2.
Using the extracted variables (Figure 2), a new Random Forest model was constructed with 500 trees. Three variables were randomly selected for each split. The estimated total error improved slightly to OOB = 33.31%, indicating that approximately 33% of the observations were misclassified by the model. The confusion matrix for this model is presented in Table 4.
The classification errors shown in Table 4 were calculated in the same way as for the previous Random Forest model (Equations (13) and (14)). The best classification results were achieved for the “no injuries” class, with 21,328 cases correctly classified and a classification error of 9.15%. This indicates very good performance, showcasing the model’s ability to identify cases with no injuries accurately. The result is slightly better than that of the initial model. Similarly, the “minor injuries” class achieved moderate accuracy. A total of 12,771 cases were correctly classified, with a classification error of 31.93%. The model frequently confused this category with “no injuries” and “severe injuries”. Significant challenges arose in classifying the “severe injuries” class. Only 1060 cases were correctly predicted, resulting in a very high classification error of 87.60%. Most cases in this category were misclassified as either “minor injuries” or “no injuries”. The most challenging category to classify was “deaths”. Only 210 cases were correctly predicted, with a classification error of 90.66%. The model struggled to differentiate this category, often confusing it with “minor injuries” or “severe injuries”. The primary reason for these discrepancies lies in the imbalance among the classes. The model performs best for the dominant class, “no injuries”, as it contains the largest number of observations. Conversely, the “severe injuries” and “deaths” categories are more challenging to predict due to their lower representation in the dataset.

3.2. Characteristics of Selected Variables

Taking into account the extracted variables, an in-depth analysis was conducted to identify patterns and trends characterizing road traffic incidents in Poland, focusing on the injury levels sustained by participants and the number of casualties.
In Poland, passenger cars are most often involved in traffic incidents, reflecting their prevalence and popularity among citizens. The vast majority of such cases result in no health consequences for participants. However, a significant number of incidents still lead to severe injuries or fatalities, highlighting the need for safer private transportation systems. The results for other types of vehicles are far better. Notable is the frequency of incidents involving heavy trucks; however, due to their greater weight and elevated driver positions, they mostly end with no injuries. A frequency heatmap for the “vehicle type” variable in terms of the number of road traffic incidents and their consequences for participants is shown in Figure 3.
Driver behavior significantly influences the number and severity of road traffic incidents. In Poland, many accidents are caused by speeding or failing to yield the right of way, often leading to severe injuries or, in extreme cases, even fatalities. Fewer incidents stem from behaviors like driving on the wrong side of the road or inadequate vehicle lighting, although these can also have serious consequences. It should be emphasized that many incidents occur even when drivers behave appropriately. While most of these do not result in health consequences, there are cases of severe injuries and fatalities. A frequency heatmap for the “driver behavior” variable in terms of the number of road traffic incidents and their consequences for participants is shown in Figure 4.
Poland’s 16 administrative regions (voivodeships) exhibit varying numbers and severities of road traffic incidents. The highest number of incidents was recorded in the Mazowieckie, Małopolskie, Łódzkie and Śląskie voivodeships, often resulting in no health consequences or minor to severe injuries. In contrast, the Lubuskie, Podlaskie, and Opolskie voivodeships reported the fewest incidents, correlating with lower casualty numbers. These disparities may result from differences in the traffic density and road infrastructure, including access to expressways and highways. A frequency heatmap for the “voivodeship” variable in terms of the number of road traffic incidents and their consequences for participants is shown in Figure 5.
Another crucial variable in terms of road safety is the type of incident, as participants can sustain varying degrees of injury depending on the specific road situation. In Poland, the most frequent incidents are side vehicle collisions, which in most cases have no impact on health or result in minor, or occasionally serious, injuries. Rear-end collisions are also quite common, typically leading to few or no health consequences. Particularly hazardous are head-on collisions and pedestrian accidents, as these categories are characterized by a high frequency of severe injuries and fatalities. Conversely, collisions with stationary vehicles are the least recorded, indicating a lower likelihood of such incidents occurring on Polish roads. A frequency heatmap for the “type of accident” variable in terms of the number of road traffic incidents and their consequences for participants is shown in Figure 6.
The consequences of road incidents can also vary depending on the participant type, such as drivers, passengers, or pedestrians. In Poland, the majority of incidents involve drivers, with most resulting in no health consequences. However, drivers also account for the highest number of incidents causing minor and severe injuries as well as fatalities. This trend may stem from the fact that drivers constitute the largest group of road users and benefit from the protective structure of vehicles. Passengers often sustain minor and severe injuries but are involved in fewer fatal incidents compared to pedestrians. Pedestrians, on the other hand, face a particularly high risk of severe injuries and fatalities due to their lack of physical protection, such as when directly hit by a vehicle. A frequency heatmap for the “type of accident participant” variable in terms of the number of road traffic incidents and their consequences for participants is shown in Figure 7.
The number of incidents and the severity of their consequences for road users also depend on the day of the week. According to statistical data from Poland, Friday stands out as the day with the highest frequency of road incidents, most of which have no health consequences. However, Friday also records the highest number of incidents resulting in minor or severe injuries, as well as fatalities. This trend is largely due to increased traffic at the end of the workweek, driven by weekend travel. Mondays and Saturdays also see a relatively high number of incidents, with Saturday’s incidents more often resulting in serious injuries or fatalities. On other days of the week, accidents involving severe injuries or fatalities are more evenly distributed. Sunday has the lowest number of incidents among all the days. A frequency heatmap for the “day of week” variable in terms of the number of road traffic incidents and their consequences for participants is shown in Figure 8.
Another critical factor in road safety in Poland is the location of the incident. The vast majority of dangerous situations occur on the roadway, as it is the primary space used by vehicles. While most roadway incidents result in no injuries, this location also accounts for the highest number of accidents involving minor and severe injuries, as well as fatalities. Pedestrian crossings are another high-risk location. Although the total number of incidents is lower compared to roadways, these incidents carry a high risk of severe injuries or fatalities. This is primarily due to the limited protection available to pedestrians and the challenges in ensuring adequate visibility. Notably fewer incidents occur in locations such as public transport stops and railway crossings, which may reflect the effectiveness of road safety measures implemented at these sites. A frequency heatmap for the “place of accident” variable in terms of the number of traffic incidents and their consequences for participants is shown in Figure 9.
It is undeniable that traveling at higher speeds impacts road safety, increasing the risk of severe injuries or fatalities in the event of an incident. The relationship between speed limits and the severity of injuries sustained in road incidents in Poland was analyzed. Generally, higher speed limits are associated with more severe injuries. For the “no injuries” category, the speed limits are the lowest, with a narrow data range and a few outliers indicating rare cases of no injuries at high speeds. In the “minor injuries” category, the speed distribution is broader, reflecting greater variability in the circumstances of the incidents. For “severe injuries”, the interquartile range significantly widens, while for “deaths”, both the interquartile range and the median increase, highlighting the significant role of higher speeds in road incidents. The results are illustrated in the box plot (Figure 10).
There is a clear relationship between the number and severity of accidents and the prevailing lighting conditions. During the analyzed period, the highest number of road incidents occurred during daylight hours. Most of these incidents resulted in no injuries to participants, largely due to the improved visibility and greater predictability of road conditions. However, daytime conditions also accounted for the highest proportion of accidents involving injuries or fatalities, as the traffic volume is significantly higher during the day. At night, on lighted roads, the number of incidents is noticeably lower. These situations mostly result in no injuries or minor injuries, although severe injuries do occur occasionally. The lowest number of traffic accidents occurs at night on unlit roads. However, the consequences of these incidents are particularly severe, as such conditions often lead to serious injuries or fatalities. A frequency heatmap for the “lighting” variable in terms of the number of road traffic incidents and their consequences for participants is shown in Figure 11.
Another variable considered in this study is sex. In Poland, men are significantly more often involved in road incidents, especially those that result in no injuries or minor injuries. When incidents involve women, they typically result in minor injuries. Notably, men experience a higher frequency of fatal incidents compared to women. This could suggest their greater participation in traffic, differences in driving styles, and, consequently, a potentially higher exposure to risk. A frequency heatmap for the “sex” variable in terms of the number of road traffic incidents and their consequences for participants is shown in Figure 12.
The number of road incidents in Poland is also influenced by pedestrian behavior, which in extreme cases can pose risks to health and life. Interestingly, the highest frequency of incidents is observed in cases where the pedestrian behaves correctly. These incidents most often result in minor or severe injuries, although fatalities are also frequent. This indicates that even when following the rules, pedestrians in Poland face numerous hazardous situations due to interactions with vehicle traffic. The second most common incidents are related to careless entry onto the roadway in front of moving vehicles. These incidents predominantly result in minor and severe injuries, although the number of fatalities is also relatively high. For other pedestrian behaviors, the statistics for hazardous incidents are significantly lower, with less variation in the level of injuries and fatalities. A frequency heatmap for the “pedestrian behavior” variable in terms of the number of road traffic incidents and their consequences for participants is shown in Figure 13.
Based on the selected and described 11 variables, the next section of this article presents the mathematical modeling of road safety in Poland using machine learning algorithms.

4. Mathematical Modeling of Road Safety in Poland

This section of the present study introduces three machine learning models: KNN, RF classification with cross-validation, and RPart classification with cross-validation. The dataset was split into a training set and a test set, and a cross-validation controller was prepared. Here, 85% of the data were allocated to the training set, while the remaining 15% were allocated to the test set. To ensure consistency and repeatability during cross-validation, the data were divided into 10 subsets (10-fold cross-validation), with each fold containing training data for a given split. Each fold was used once as a validation set and the other folds as a training set.

4.1. K-Nearest Neighbors (KNN)

K-Nearest Neighbors (KNN) is one of the simplest machine learning algorithms, primarily used for classification tasks. The parameter k (the number of neighbors) significantly influences the model’s performance. The KNN model was evaluated for different values of the parameter k. The results are presented in Table 5.
The accuracy was used to select the optimal model. The proportion of correct predictions relative to all the samples reached the highest accuracy of 64.82% for k = 9. The Kappa value, a metric that accounts for chance agreement, was also the highest. The value Kappa = 0.4261 indicates moderate agreement between the predicted and actual classes. Thus, for the KNN model, k = 9 was assumed. The confusion matrix for this model is presented in Table 6.
For the KNN model, a very low p-value for the McNemar test was obtained (χ2 < 2.2 × 10−16). This result shows that the difference between the number of misclassifications for one class and the misclassifications for the other class is statistically significant. This means that the model makes classification errors in an asymmetric manner. The model demonstrates strong performance in identifying observations for the “no injuries” class, achieving a high sensitivity of 88.9% and a relatively high specificity of 73.62%. The model performs well with this class and is less likely to assign other classes to “no injuries”–the balanced accuracy is 81.26%. For the “minor injuries” class, the sensitivity is 62.72%, and the specificity is 74.49%. The positive predictive value (PPV) of 57.38% indicates that the model frequently misclassifies other classes as “minor injuries”, leading to the balanced accuracy of 68.61%. The model struggles significantly with the “severe injuries” class. The sensitivity is notably low at 14.83%, although the specificity is high at 95.25%, meaning the model rarely misclassifies other classes as “severe injuries”. The balanced accuracy of 55.04% indicates poor performance in this class. The most critical issue lies in the “deaths” class, where the model essentially fails to detect it. The sensitivity is extremely low at 6.23%, although the specificity is very high at 99.34%, indicating that the model almost never misclassifies other classes as “deaths”. The balanced accuracy of 52.79% further underscores the model’s challenges in accurately identifying this class.

4.2. RF Classification with Cross-Validation

Another model is Random Forest with cross-validation. First, the mtry parameter, which defines the number of randomly selected predictors considered at each node split in the random forest trees, was selected. Various mtry values were tested, and the results are shown in Table 7.
The highest accuracy and Kappa values were achieved for the parameter mtry = 44, and this value was subsequently used in the model. The confusion matrix for Random Forest with cross-validation is presented in Table 8.
For this model, as for KNN, the value of McNemar’s test statistic was very low (χ2 < 2.2 × 10−16). Random Forest also makes classification errors in an asymmetric manner. The number of cases in which the model incorrectly classified an example as one of the classes differs significantly from the number of cases in which the model incorrectly classified an example as another class. The accuracy of this model is 63.02%, indicating moderate performance, similar to the previous model, KNN. Similarly, the model performs well for the “no injuries” and “minor injuries” classes but struggles significantly with the less frequent “severe injuries” and “deaths” classes.
The results for each class are as follows:
1.
“No injuries”:
  • Sensitivity: 84.95%—the model effectively identifies samples belonging to this class;
  • Specificity: 79.02%—the model less frequently misclassifies other classes as “no injuries”;
  • Balanced accuracy: 81.98%—demonstrates strong performance for this class.
2.
“Minor injuries”:
  • Sensitivity: 59.03%—moderate ability to detect this class;
  • Specificity: 75.03%—the model performs better at excluding other classes;
  • Balanced accuracy: 67.03%.
3.
“Severe injuries”:
  • Sensitivity: 24.90%—the model struggles to correctly identify this class;
  • Specificity: 90.87%—the majority of other classes are not misclassified as “severe injuries”;
  • Balanced accuracy: 57.88%.
4.
“Deaths”:
  • Sensitivity: 12.17%—very low sensitivity indicates that the model hardly detects this class;
  • Specificity: 98.44%—the model rarely misclassifies other classes as “deaths”;
  • Balanced accuracy: 55.30%.

4.3. RPart Classification with Cross-Validation

The final proposed model is RPart classification with cross-validation. In this model, the present study began by selecting the cp complexity parameter, which controls the level of pruning in the decision tree. The higher the value of cp, the more simplified the tree, which reduces the risk of overlearning but can lead to underlearning. Various cp values were tested, with the results summarized in Table 9.
The optimal cp value, providing the highest accuracy and Kappa, was 0.0396, and therefore, this value was adopted for the model. The confusion matrix for the RPart classification with cross-validation is presented in Table 10.
For RPart, the value of McNemar’s test statistic was very low (χ2 < 2.2 × 10−16), which indicates that similar to KNN and RF, this model makes classification errors in an asymmetric manner. The accuracy of this model is 62.86%, meaning it is moderate. Similar to the KNN and RF models, RPart performs well for certain classes but struggles to equally identify all of them.
The results for each class are as follows:
1.
“No injuries”:
  • Sensitivity: 97.13%—the model excels in identifying this class, likely due to its high representation in the dataset;
  • Specificity: 56.18%—the model struggles to distinguish this class from others, particularly “minor injuries”;
  • Balanced accuracy: 76.66%—while the majority of predictions for this class are correct, the model frequently misclassifies other classes as “no injuries”.
2.
“Minor injuries”:
  • Sensitivity: 56.11%—the model correctly identifies slightly more than half of the cases in this class;
  • Specificity: 80.31%—the model is effective at recognizing when observations do not belong to “minor injuries” class;
  • Balanced accuracy: 68.21%—most of the instances assigned to this class are correct.
3.
“Severe injuries”:
  • Sensitivity: 0%—the model completely fails to identify this class, with no cases correctly classified as “severe injuries”;
  • Specificity: 100%—no observations are misclassified into this class, but at the cost of completely ignoring this class;
  • Balanced accuracy: 50.00%.
4.
“Deaths”:
  • Sensitivity: 0%—similar to the “severe injuries” class, the model does not identify any instances of this class;
  • Specificity: 100%—the model never misclassifies other observations as “death”;
  • Balanced accuracy: 50.00%.

5. Discussion of Results

Research on road safety in Poland reveals that despite preventive measures, the number of accidents and their consequences remain high. To address this issue, this study applied a machine learning (ML) approach, which enabled the analysis of large datasets to identify key factors influencing road safety and develop mathematical models for predicting traffic incidents and their consequences for participants. The key variables identified as having the strongest impact on road safety in Poland include the type of vehicle, driver behavior, voivodeship, type of incident, type of the participant, and day of the week. Other significant factors include the location of the incident, speed, lighting conditions, pedestrian behavior, and sex. All these variables were incorporated into the mathematical modeling process.
This study’s goal of developing mathematical models based on ML algorithms to describe road safety in Poland was successfully achieved. Three proposed models—k-Nearest Neighbors (KNN), Random Forest (RF), and Recursive Partitioning and Regression Trees (RPart)—produced similar results:
1.
k-Nearest Neighbors (KNN):
  • Accuracy—64.2%;
  • Kappa—0.4162;
  • Sensitivity “no injuries”—88.90%;
  • Sensitivity “minor injuries”—62.72%;
  • Sensitivity “severe injuries”—14.83%;
  • Sensitivity “deaths”—6.23%.
2.
RF classification with cross-validation:
  • Accuracy—63.02%;
  • Kappa—0.414;
  • Sensitivity “no injuries”—84.95%;
  • Sensitivity “minor injuries”—59.03%;
  • Sensitivity “severe injuries”—24.90%;
  • Sensitivity “deaths”—12.17%.
3.
RPart classification with cross-validation:
  • Accuracy—62.86%;
  • Kappa—0.3664;
  • Sensitivity “no injuries”—97.13%;
  • Sensitivity “minor injuries”—56.11%;
  • Sensitivity “severe injuries”—0%;
  • Sensitivity “deaths”—0%.
Moreover, the p-value for the McNemar test was very low for each of the models (χ2 < 2.2 × 10−16). This result shows that the difference between the number of misclassifications for one class and the number of misclassifications for the other class is statistically significant. The number of cases in which the model incorrectly classified an example as one of the classes differs significantly from the number of cases in which the model incorrectly classified an example as another class. Therefore, the models make classification errors in an asymmetric manner. This is probably due to the fact that the proposed models may be more “biased” toward one class, more often confusing it with the other, which suggests a problem with the data balance and confirms the uneven distribution of classes in the dataset. Among the models, k-Nearest Neighbors achieved the highest sensitivity, although the difference compared to Random Forest and RPart was small. KNN performed better at classifying the “no injuries” class and demonstrated higher specificity for the “deaths” class. The Kappa coefficient for KNN and RF indicates moderate agreement (Kappa ≈ 0.41), while RPart achieved a slightly lower score (Kappa = 0.383), suggesting its classifications are somewhat more random. Overall, RPart delivered the weakest results, particularly for rare classes like “severe injuries” and “deaths,” where it failed to recognize any cases. However, all the models faced challenges in classifying rare classes, highlighting the need for alternative methods to analyze such datasets. This challenge will be the focus of further research by the authors.

6. Conclusions

In summary, it can be concluded that Random Forest (RF) is the best choice for handling imbalanced datasets, especially when identifying rare classes like “severe injuries” and “deaths” is the primary goal. For situations where achieving the highest overall accuracy is critical, k-Nearest Neighbors (KNN) provides a reasonable compromise. Meanwhile, RPart can serve as a fast baseline model but requires improvements to effectively manage rare classes.
This research demonstrates that ML models have the potential to predict traffic hazards and their consequences. In the long term, these models could become valuable tools for managing road safety. However, there are still limitations, mainly related to the availability, collection and sharing of data, which significantly affect the performance of the proposed models. First of all, many minor collisions are not reported to the police, which means that the statistics may not include all events. Moreover, the data currently provided do not contain details on the traffic volume, weather conditions, quality of infrastructure or technical condition of vehicles. There is no doubt that factors such as atmospheric precipitation or parameters such as the road width, lane width or road surface condition may affect the number of road traffic incidents and their severity for participants. Another issue is the fact that the available statistics are based mainly on reports and notifications, which not only prevents full consideration of all aspects but may also cause inconsistencies related to data collection and even errors resulting from the human factor, e.g., incorrect description of the circumstances of the incident. This only shows that a transformation is necessary toward the use of advanced tools for monitoring road traffic incidents. Moreover, there is a lack of integration of available police statistics with other sources. Fully harnessing the potential of ML algorithms requires a unified system for collecting and sharing data on road incidents, traffic volumes and even weather conditions. Establishing such a system should be a priority for Polish policymakers aiming to improve road safety.
Taking into account the obtained results, future research on the use of machine learning tools in the context of road safety in Poland should focus on developing models that, thanks to detailed and consistent data, will be able to predict road incidents and their consequences depending on the weather conditions, the traffic intensity or the condition and quality of the road infrastructure. Such ML models could not only help identify specific weather conditions conducive to accidents but also assess the importance of the condition of the road surface or geometry in the context of participant safety. Another reasonable direction for future research may be the development of spatial and temporal models based on ML that allow prediction of the place and time of increased risk of accidents. Integration with geographic data (GIS) could identify spatial patterns regarding the probability of road traffic events, along with their potential consequences. Ultimately, from a broader perspective, ML models could positively impact the overall road traffic safety in Poland by finding applications in designing safer road infrastructure, optimizing traffic management, and implementing changes to regulations, such as speed limits.

Author Contributions

Conceptualization, A.B.; methodology, A.B. and S.S.; formal analysis, A.B. and S.S.; data curation, A.B.; writing—original draft preparation, S.S.; writing—review and editing, A.B. and S.S.; visualization, S.S.; supervision, A.B. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The raw data supporting the conclusions of this article will be made available by the authors on request.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Bougna, T.; Hundal, G.; Taniform, P. Quantitative analysis of the social costs of road traffic crashes literature. Accid. Anal. Prev. 2022, 165, 106282. [Google Scholar] [CrossRef] [PubMed]
  2. Road Accidents–Annual Reports of the Polish Police Headquarters. Available online: https://statystyka.policja.pl/st/ruch-drogowy/76562,wypadki-drogowe-raporty-roczne.html (accessed on 25 November 2024).
  3. Road Safety Status Reports. Available online: https://www.krbrd.gov.pl/baza-wiedzy/raporty-o-stanie-brd/ (accessed on 25 November 2024).
  4. Ehsani, J.P.; Michael, J.P.; Mackenzie, E.J. The Future of Road Safety: Challenges and opportunities. Milbank Q. 2023, 101, 613–636. [Google Scholar] [CrossRef]
  5. Li, X.; Song, K.; Shi, J. Degradation generation and prediction based on machine learning methods: A comparative study. Eksploat. I Niezawodn. —Maint. Reliab. 2024, 27, 192168. [Google Scholar] [CrossRef]
  6. Adamkiewicz, A.; Nikończuk, P. An attempt at applying machine learning in diagnosing marine ship engine turbochargers. Eksploat. I Niezawodn. —Maint. Reliab. 2022, 24, 795–804. [Google Scholar] [CrossRef]
  7. Boukerche, A.; Wang, J. Machine learning-based traffic prediction models for Intelligent Transportation Systems. Comput. Netw. 2020, 181, 107530. [Google Scholar] [CrossRef]
  8. Yang, Y.; He, K.; Wang, Y.; Yuan, Z.; Yin, Y.; Guo, M. Identification of dynamic traffic crash risk for cross-area freeways based on statistical and machine learning methods. Phys. A Stat. Mech. Appl. 2022, 595, 127083. [Google Scholar] [CrossRef]
  9. Morales, F.J.; Reyes, A.; Caceres, N.; Romero, L.M.; Benitez, F.G.; Morgado, J.; Duarte, E. A Machine Learning Methodology to Predict Alerts and Maintenance Interventions in Roads. Road Mater. Pavement Des. 2020, 22, 2267–2288. [Google Scholar] [CrossRef]
  10. Bajwoluk, T.; Langer, P.; Skrzypczak, I.; Sikora, A. Spatial Transitions of Areas near Highway Interchanges of the Eastern A4 Highway Section in Poland. J. Transp. Geogr. 2024, 121, 104005. [Google Scholar] [CrossRef]
  11. Koziarski, S.M. Expanding the Network of Highways and Expressways in the Post-Socialist Countries of the European Union in the Years 2004–2019. Transp. Geogr. Pap. Pol. Geogr. Soc. 2020, 23, 41–60. [Google Scholar] [CrossRef]
  12. Szumska, E.; Frej, D.; Grabski, P. Analysis of the Causes of Vehicle Accidents in Poland in 2009–2019. LOGI—Sci. J. Transp. Logist. 2020, 11, 76–87. [Google Scholar] [CrossRef]
  13. Romanowska, A.; Pangsy-Kania, S.; Budzyński, M.; Wierzbicka, K.; Prystrom, J. Determinants and Effects of Poland’s Road Accidents in the Context of the 2030 Agenda for Sustainable Development—Poviat Level Analysis for the Years 2010–2019. Econ. Environ. 2022, 82, 173–193. [Google Scholar] [CrossRef]
  14. Pińskwar, I.; Choryński, A.; Graczyk, D. Good Weather for a Ride (or Not?): How Weather Conditions Impact Road Accidents —a Case Study from Wielkopolska (Poland). Int. J. Biometeoro. 2024, 68, 317–331. [Google Scholar] [CrossRef]
  15. Burzyńska, M.; Pikala, M. Decreasing Trends in Road Traffic Mortality in Poland: A Twenty-Year Analysis. International Int. J. Environ. Res. Public Health 2021, 18, 10411. [Google Scholar] [CrossRef] [PubMed]
  16. Frej, D.; Ludwinek, K. Analysis of road accidents in 2002–2019 on the example of Poland. Arch. Automot. Eng. —Arch. Motoryz. 2020, 89, 5–18. [Google Scholar] [CrossRef]
  17. Jurecki, R.S. Analysis of Road Safety in Poland after Accession to the European Union. Commun. —Sci. Lett. Univ. Zilina 2020, 22, 60–67. [Google Scholar] [CrossRef]
  18. Gorzelanczyk, P.; Jurkovič, M.; Skibińska, J.; Kalina, T. Road safety and the causes of road accidents in Poland. Transp. Probl. 2022, 17, 20–33. [Google Scholar] [CrossRef]
  19. Borucka, A.; Pyza, D. Influence of meteorological conditions on road accidents. A model Indexed by: For observations with excess zeros. Eksploat. I Niezawodn. —Maint. Reliab. 2021, 23, 586–592. [Google Scholar] [CrossRef]
  20. Becker, N.; Rust, H.W.; Ulbrich, U. Predictive modeling of hourly probabilities for weather-related road accidents. Nat. Hazards Earth Syst. Sci. 2020, 20, 2857–2871. [Google Scholar] [CrossRef]
  21. Sánchez González, S.; Bedoya-Maya, F.; Calatayud, A. Understanding the Effect of Traffic Congestion on Accidents Using Big Data. Sustainability 2021, 13, 7500. [Google Scholar] [CrossRef]
  22. Borucka, A.; Kozłowski, E.; Oleszczuk, P.; Świderski, A. Predictive analysis of the impact of the time of day on road accidents in Poland. Open Eng. 2020, 11, 142–150. [Google Scholar] [CrossRef]
  23. Gorzelanczyk, P.; Tylicki, H. Methodology for Optimizing Factors Affecting Road Accidents in Poland. Forecasting 2023, 5, 336–350. [Google Scholar] [CrossRef]
  24. Subhan, F.; Zhao, S.; Diop, E.B.; Ali, Y.; Zhou, H. Public intention to pay for road safety improvement: A case study of Pakistan. Accid. Anal. Prev. 2021, 160, 106315. [Google Scholar] [CrossRef]
  25. Warczek, J.; Żak, K. The assessment of the technical condition of a tire belt using computed tomography. Eksploat. I Niezawodn. —Maint. Reliab. 2024, 26, 183177. [Google Scholar] [CrossRef]
  26. Pędzierska, M.; Pawlak, P.; Kruszewski, M.; Jamson, S. Estimated Assessment Of The Potential Impact Of Driver Assistance Systems Used in Automated Vehicles on the Level of Road Safety in Poland. Transp. Probl. 2020, 15, 325–338. [Google Scholar] [CrossRef]
  27. Masello, L.; Castignani, G.; Sheehan, B.; Murphy, F.; McDonnell, K. On the road safety benefits of advanced driver assistance systems in different driving contexts. Transp. Res. Interdiscip. Perspect. 2022, 15, 100670. [Google Scholar] [CrossRef]
  28. Jamroz, K.; Romanowska, A.; Michalski, L.; Żukowska, J. Vision Zero in Poland. In The Vision Zero Handbook, 1st ed.; Edvardsson Björnberg, K., Belin, M.Å., Hansson, S.O., Tingvall, C., Eds.; Springer: Cham, Switzerland, 2022; pp. 1–40. [Google Scholar]
  29. Shen, Y.; Hermans, E.; Bao, Q.; Wets, G. Towards better road safety management: Lessons learned from international benchmarking. Accid. Anal. Prev. 2020, 138, 105484. [Google Scholar] [CrossRef] [PubMed]
  30. Graba, M.; Bieniek, A.; Prażnowski, K.; Hennek, K.; Mamala, J.; Burdzik, R.; Śmieja, M. Analysis of energy efficiency and dynamics during car acceleration. Eksploat. I Niezawodn. —Maint. Reliab. 2023, 25, 17. [Google Scholar] [CrossRef]
  31. Kozłowski, E.; Borucka, A.; Świderski, A.; Skoczyński, P. Classification Trees in the Assessment of the Road–Railway Accidents Mortality. Energies 2021, 14, 3462. [Google Scholar] [CrossRef]
  32. Murawski, J.; Szczepański, E.; Jacyna-Gołda, I.; Izdebski, M.; Jankowska-Karpa, D. Intelligent mobility: A model for assessing the safety of children traveling to school on a school bus with the use of intelligent bus stops. Eksploat. I Niezawodn. —Maint. Reliab. 2022, 24, 695–706. [Google Scholar] [CrossRef]
  33. Kozłowski, E.; Borucka, A.; Oleszczuk, P.; Leszczyński, N. Evaluation of readiness of the technical system using the semi-Markov model with selected sojourn time distributions. Eksploat. I Niezawodn. —Maint. Reliab. 2024, 26, 191545. [Google Scholar] [CrossRef]
  34. Ziółkowski, J.; Oszczypała, M.; Lęgas, A.; Konwerski, J.; Małachowski, J. A method for calculating the technical readiness of aviation refuelling vehicles. Eksploat. I Niezawodn. —Maint. Reliability. 2024, 26, 187888. [Google Scholar] [CrossRef]
  35. Kozłowski, E.; Borucka, A.; Oleszczuk, P.; Jałowiec, T. Evaluation of the maintenance system readiness using the semi-Markov model taking into account hidden factors. Eksploat. I Niezawodn. —Maint. Reliab. 2023, 25, 172857. [Google Scholar] [CrossRef]
  36. Silva, P.B.; Andrade, M.; Ferreira, S. Machine Learning Applied to Road Safety Modeling: A Systematic Literature Review. J. Traffic Transp. Eng. (Engl. Ed.) 2020, 7, 775–790. [Google Scholar] [CrossRef]
  37. Chai, A.B.Z.; Lau, B.T.; Kit, M.; McCarthy, C. Enhancing Road Safety with Machine Learning: Current Advances and Future Directions in Accident Prediction Using Non-Visual Data. Eng. Appl. Artif. Intell. 2024, 137, 109086. [Google Scholar] [CrossRef]
  38. Guido, G.; Shaffiee Haghshenas, S.; Shaffiee Haghshenas, S.; Vitale, A.; Astarita, V.; Park, Y.; Geem, Z.W. Evaluation of Contributing Factors Affecting Number of Vehicles Involved in Crashes Using Machine Learning Techniques in Rural Roads of Cosenza, Italy. Safety 2022, 8, 28. [Google Scholar] [CrossRef]
  39. Banerjee, K.; Bali, V.; Sharma, A.; Aggarwal, D.; Yadav, A.; Shukla, A.; Srivastav, P. Traffic Accident Risk Prediction Using Machine Learning. In Proceedings of the 2022 International Mobile and Embedded Technology Conference (MECON), Noida, India, 10–11 March 2022; pp. 76–82. [Google Scholar]
  40. Pourroostaei Ardakani, S.; Liang, X.; Mengistu, K.T.; So, R.S.; Wei, X.; He, B.; Cheshmehzangi, A. Road Car Accident Prediction Using a Machine-Learning-Enabled Data Analysis. Sustainability 2023, 15, 5939. [Google Scholar] [CrossRef]
  41. Saravanan, A.; Malathi, M.; Manonmani, M.; Sanathani, T.; Kumar, A.S. Prediction of Road Accidents Using Machine Learning Technique. In Proceedings of the 2020 4th International Conference on Electronics, Communication and Aerospace Technology (ICECA), Coimbatore, India, 2–4 December 2021. [Google Scholar]
  42. Fan, Z.; Liu, C.; Cai, D.; Yue, S. Research on Black Spot Identification of Safety in Urban Traffic Accidents Based on Machine Learning Method. Saf. Sci. 2019, 118, 607–616. [Google Scholar] [CrossRef]
  43. Olugbade, S.; Ojo, S.; Imoize, A.L.; Isabona, J.; Alaba, M.O. A Review of Artificial Intelligence and Machine Learning for Incident Detectors in Road Transport Systems. Math. Comput. Appl. 2022, 27, 77. [Google Scholar] [CrossRef]
  44. Do Vale Saraiva, T.; Campos, C.A.V. An approach using machine learning and public data to detect traffic jams. In Proceedings of the 2021 International Wireless Communications and Mobile Computing (IWCMC), Harbin, China, 28 June–2 July 2021; pp. 675–680. [Google Scholar]
  45. Chawla, P.; Hasurkar, R.; Bogadi, C.R.; Korlapati, N.S.; Rajendran, R.; Ravichandran, S.; Tolem, S.C.; Gao, J.Z. Real-Time Traffic Congestion Prediction Using Big Data and Machine Learning Techniques. World J. Eng. 2022, 21, 140–155. [Google Scholar] [CrossRef]
  46. Ghandour, R.; Potams, A.J.; Boulkaibet, I.; Neji, B.; Al Barakeh, Z. Driver Behavior Classification System Analysis Using Machine Learning Methods. Appl. Sci. 2021, 11, 10562. [Google Scholar] [CrossRef]
  47. Lattanzi, E.; Castellucci, G.; Freschi, V. Improving Machine Learning Identification of Unsafe Driver Behavior by Means of Sensor Fusion. Appl. Sci. 2020, 10, 6417. [Google Scholar] [CrossRef]
  48. Tatar, G.; Bayar, S.; Cicek, I.; Niar, S. Recent Advances in Machine Learning Based Advanced Driver Assistance System Applications. Microprocess. Microsyst. 2024, 110, 105101. [Google Scholar] [CrossRef]
  49. Merbah, A.; Ben-Othman, J. Optimizing Traffic Flow with Reinforcement Learning: A Study on Traffic Light Management. IEEE Trans. Intell. Transp. Syst. 2024, 25, 7467–7476. [Google Scholar] [CrossRef]
  50. Navarro-Espinoza, A.; López-Bonilla, O.R.; García-Guerrero, E.E.; Tlelo-Cuautle, E.; López-Mancilla, D.; Hernández-Mejía, C.; Inzunza-González, E. Traffic Flow Prediction for Smart Traffic Lights Using Machine Learning Algorithms. Technologies 2022, 10, 5. [Google Scholar] [CrossRef]
  51. Ho, M.C.; Lim, J.M.-Y.; Soon, K.L.; Chong, C.Y. An Improved Pheromone-Based Vehicle Rerouting System to Reduce Traffic Congestion. Appl. Soft Comput. 2019, 84, 105702. [Google Scholar] [CrossRef]
  52. Karballaeezadeh, N.; Zaremotekhases, F.; Shamshirband, S.; Mosavi, A.; Nabipour, N.; Csiba, P.; Várkonyi-Kóczy, A.R. Intelligent Road Inspection with Advanced Machine Learning; Hybrid Prediction Models for Smart Mobility and Transportation Maintenance Systems. Energies 2020, 13, 1718. [Google Scholar] [CrossRef]
  53. Fu, T.; Li, X.; Xu, W.; Wang, J.; Zhang, L.; Ye, L.; Yu, R. Risk Analysis of Bridge Maintenance Accidents: A Two-Stage LEC Method and Bayesian Network Approach. Int. J. Transp. Sci. Technol. 2023, 15, 51–64. [Google Scholar] [CrossRef]
  54. Singh, P.; Bansal, A.; Kamal, A.E.; Kumar, S. Road Surface Quality Monitoring Using Machine Learning Algorithm. In Intelligent Manufacturing and Energy Sustainability. Smart Innovation, Systems and Technologies; Reddy, A.N.R., Marla, D., Favorskaya, M.N., Satapathy, S.C., Eds.; Springer: Singapore, 2022; Volume 265. [Google Scholar]
  55. Han, H.; Guo, X.; Yu, H. Variable selection using Mean Decrease Accuracy and Mean Decrease Gini based on Random Forest. In Proceedings of the 2016 7th IEEE International Conference on Software Engineering and Service Science (ICSESS), Beijing, China, 26–28 August 2016; pp. 219–224. [Google Scholar]
  56. Jaiswal, J.K.; Samikannu, R. Application of Random Forest Algorithm on Feature Subset Selection and Classification and Regression. In Proceedings of the 2017 World Congress on Computing and Communication Technologies (WCCCT), Tiruchirappalli, India, 2–4 February 2017; pp. 65–68. [Google Scholar]
  57. Zhang, S.; Li, X.; Zong, M.; Zhu, X.; Cheng, D. Learning k for kNN classification. ACM Trans. Intell. Syst. Technol. 2017, 8, 1–19. [Google Scholar] [CrossRef]
  58. Mahesh, B. Machine learning algorithms—A review. Int. J. Sci. Res. 2020, 9, 381–386. [Google Scholar] [CrossRef]
  59. Uddin, S.; Haque, I.; Lu, H.; Moni, M.A.; Gide, E. Comparative Performance Analysis of K-Nearest Neighbour (KNN) Algorithm and Its Different Variants for Disease Prediction. Sci. Rep. 2022, 12, 6256. [Google Scholar] [CrossRef] [PubMed]
  60. Ren, Q.; Cheng, H.; Han, H. Research on Machine Learning Framework Based on Random Forest Algorithm. AIP Conf. Pro. 2017, 1820, 080020. [Google Scholar]
  61. Speiser, J.L.; Miller, M.E.; Tooze, J.; Ip, E. A Comparison of Random Forest Variable Selection Methods for Classification Prediction Modeling. Expert Syst. Appl. 2019, 134, 93–101. [Google Scholar] [CrossRef]
  62. Wong, T.-T. Performance Evaluation of Classification Algorithms by K-Fold and Leave-One-out Cross Validation. Pattern Recognit. 2015, 48, 2839–2846. [Google Scholar] [CrossRef]
  63. Allgaier, J.; Pryss, R. Cross-Validation Visualized: A Narrative Guide to Advanced Methods. Mach. Learn. Knowl. Extr. 2024, 6, 1378–1388. [Google Scholar] [CrossRef]
  64. Genuer, R.; Poggi, J.M. CART. In Random Forests with R. Use R! 1st ed.; Hornik, K., Parmigiani, G., Eds.; Springer: Cham, Switzerland, 2020; pp. 9–32. [Google Scholar]
  65. Dehghan, S.; Rabiei, R.; Choobineh, H.; Maghooli, K.; Nazari, M.; Vahidi-Asl, M. Comparative Study of Machine Learning Approaches Integrated with Genetic Algorithm for IVF Success Prediction. PLoS ONE 2024, 19, e0310829. [Google Scholar] [CrossRef]
  66. Turska, E.; Jurga, S.; Piskorski, J. Mood Disorder Detection in Adolescents by Classification Trees, Random Forests and XGBoost in Presence of Missing Data. Entropy 2021, 23, 1210. [Google Scholar] [CrossRef]
  67. Berrar, D. Cross-Validation. Encycl. Bioinform. Comput. Biol. 2019, 1, 542–545. [Google Scholar]
  68. Erickson, B.J.; Kitamura, F. Magician’s Corner: 9. Performance Metrics for Machine Learning Models. Radiol. Artif. Intell. 2021, 3, e200126. [Google Scholar] [CrossRef]
  69. Jeppesen, J.H.; Jacobsen, R.H.; Inceoglu, F.; Toftegaard, T.S. A cloud detection algorithm for satellite imagery based on Deep Learning. Remote Sens. Environ. 2019, 229, 247–259. [Google Scholar] [CrossRef]
  70. De Diego, I.M.; Redondo, A.R.; Fernández, R.R.; Navarro, J.; Moguerza, J.M. General Performance Score for Classification Problems. Appl. Intell. 2022, 52, 12049–12063. [Google Scholar] [CrossRef]
  71. Rainio, O.; Teuho, J.; Klén, R. Evaluation Metrics and Statistical Tests for Machine Learning. Sci. Rep. 2024, 14, 6086. [Google Scholar] [CrossRef]
  72. Bland, M. An Introduction to Medical Statistics, 4th ed.; Oxford University Press: Oxford, UK, 2015. [Google Scholar]
  73. Sun, S. Meta-Analysis of Cohen’s Kappa. Health Serv. Outcomes Res. Methodol. 2011, 11, 145–163. [Google Scholar] [CrossRef]
  74. Ghandour, A.J.; Hammoud, H.; Al-Hajj, S. Analyzing Factors Associated with Fatal Road Crashes: A Machine Learning Approach. Int. J. Environ. Res. Public Health 2020, 17, 4111. [Google Scholar] [CrossRef]
  75. Ha, N.T.; Manley-Harris, M.; Pham, T.D.; Hawes, I. A Comparative Assessment of Ensemble-Based Machine Learning and Maximum Likelihood Methods for Mapping Seagrass Using Sentinel-2 Imagery in Tauranga Harbor, New Zealand. Remote Sens. 2020, 12, 355. [Google Scholar] [CrossRef]
  76. CRAN Task View: Machine Learning & Statistical Learning. Available online: https://cran.r-project.org/web/views/MachineLearning.html (accessed on 25 November 2024).
Figure 1. Confusion matrix with calculations of the basic metrics.
Figure 1. Confusion matrix with calculations of the basic metrics.
Applsci 15 00861 g001
Figure 2. Mean decrease Gini for the selected variables.
Figure 2. Mean decrease Gini for the selected variables.
Applsci 15 00861 g002
Figure 3. Frequency heatmap for the “vehicle type” variable in terms of road safety in Poland.
Figure 3. Frequency heatmap for the “vehicle type” variable in terms of road safety in Poland.
Applsci 15 00861 g003
Figure 4. Frequency heatmap for the “driver behavior” variable in terms of road safety in Poland.
Figure 4. Frequency heatmap for the “driver behavior” variable in terms of road safety in Poland.
Applsci 15 00861 g004
Figure 5. Frequency heatmap for the “voivodeship” variable in terms of road safety in Poland.
Figure 5. Frequency heatmap for the “voivodeship” variable in terms of road safety in Poland.
Applsci 15 00861 g005
Figure 6. Frequency heatmap for the “type of accident” variable in terms of road safety in Poland.
Figure 6. Frequency heatmap for the “type of accident” variable in terms of road safety in Poland.
Applsci 15 00861 g006
Figure 7. Frequency heatmap for the “type of accident participant” variable in terms of road safety in Poland.
Figure 7. Frequency heatmap for the “type of accident participant” variable in terms of road safety in Poland.
Applsci 15 00861 g007
Figure 8. Frequency heatmap for the “day of week” variable in terms of road safety in Poland.
Figure 8. Frequency heatmap for the “day of week” variable in terms of road safety in Poland.
Applsci 15 00861 g008
Figure 9. Frequency heatmap for the “place of accident” variable in terms of road safety in Poland.
Figure 9. Frequency heatmap for the “place of accident” variable in terms of road safety in Poland.
Applsci 15 00861 g009
Figure 10. Box plot of the severity of road traffic incidents in Poland depending on the speed limit.
Figure 10. Box plot of the severity of road traffic incidents in Poland depending on the speed limit.
Applsci 15 00861 g010
Figure 11. Frequency heatmap for the “lighting” variable in terms of road safety in Poland.
Figure 11. Frequency heatmap for the “lighting” variable in terms of road safety in Poland.
Applsci 15 00861 g011
Figure 12. Frequency heatmap for the “sex” variable in terms of road safety in Poland.
Figure 12. Frequency heatmap for the “sex” variable in terms of road safety in Poland.
Applsci 15 00861 g012
Figure 13. Frequency heatmap for the “pedestrian behavior” variable in terms of road safety in Poland.
Figure 13. Frequency heatmap for the “pedestrian behavior” variable in terms of road safety in Poland.
Applsci 15 00861 g013
Table 1. Confusion matrix form.
Table 1. Confusion matrix form.
Actual Class → 1
Predicted Class ↓ 2
Class 1 Class 2...Class h
Class 1 N11N12...N1h
Class 2N21N22...N2h
...............
Class h Nh1Nh2...Nhh
1 Horizontal arrow refers to rows (Actual Class); 2 Vertical arrow refers to columns (Predicted Class).
Table 2. Confusion matrix for the Random Forest model.
Table 2. Confusion matrix for the Random Forest model.
Actual ClassNo InjuriesMinor InjuriesSevere Injuries DeathsClass. Error [%]
No injuries21,5461811106138.22%
Minor injuries488312,8988938831.25%
Severe injuries167758439299689.13%
Deaths573124526616492.70%
Table 3. Mean decrease Gini for the studied variables.
Table 3. Mean decrease Gini for the studied variables.
No.VariableMean Decrease Gini
1Vehicle type3349.19403
2Driver behavior3265.63861
3Voivodeship2290.05636
4Type of accident2161.99595
5Type of accident participant2096.33577
6Day of the week1319.50264
7Place of accident961.22562
8Speed limit811.02891
9Lighting671.76051
10Sex601.05397
11Pedestrian behavior466.14488
12Type of road456.43282
13Seat in the vehicle410.70926
14Crossroad375.25493
15Horizontal road marking313.85263
16Type of area244.81922
17Weekend day228.06105
18Traffic light223.69613
19Feast day137.43232
20Other causes130.26838
21Public road58.53400
22Road surface44.12633
23Traffic zone33.36683
24Residential zone27.65299
Table 4. Confusion matrix for the Random Forest model with a reduced number of variables.
Table 4. Confusion matrix for the Random Forest model with a reduced number of variables.
Actual ClassNo InjuriesMinor InjuriesSevere Injuries DeathsClass. Error [%]
No injuries21,3281962161259.15
Minor injuries475412,771112910831.93
Severe injuries16215747106011787.60
Deaths530122428421090.66
Table 5. KNN results for different values of the parameter k.
Table 5. KNN results for different values of the parameter k.
kAccuracyKappa
50.63930.4179
70.64480.4232
90.64820.4261
Table 6. Confusion matrix of the KNN model for k = 9.
Table 6. Confusion matrix of the KNN model for k = 9.
Actual ClassNo InjuriesMinor InjuriesSevere Injuries Deaths
No injuries3130798271100
Minor injuries3471765795169
Severe injuries4122919047
Deaths3222521
Table 7. Results for different mtry values.
Table 7. Results for different mtry values.
mtryAccuracyKappa
20.61850.3470
440.63350.4195
860.62290.4062
Table 8. Confusion matrix for the Random Forest model with cross-validation for mtry = 44.
Table 8. Confusion matrix for the Random Forest model with cross-validation for mtry = 44.
Actual ClassNo InjuriesMinor InjuriesSevere Injuries Deaths
No injuries299165020971
Minor injuries4211661714148
Severe injuries8844431977
Deaths21593941
Table 9. Results for different cp values.
Table 9. Results for different cp values.
cpAccuracyKappa
0.039644950.63690.3835
0.064164310.60280.3172
0.269713010.53150.1763
Table 10. Confusion matrix for the RPart classification model with cross-validation for cp = 0.0396.
Table 10. Confusion matrix for the RPart classification model with cross-validation for cp = 0.0396.
Actual ClassNo InjuriesMinor InjuriesSevere Injuries Deaths
No injuries34201235527180
Minor injuries1011579754157
Severe injuries0000
Deaths0000
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Borucka, A.; Sobczuk, S. The Use of Machine Learning Methods in Road Safety Research in Poland. Appl. Sci. 2025, 15, 861. https://doi.org/10.3390/app15020861

AMA Style

Borucka A, Sobczuk S. The Use of Machine Learning Methods in Road Safety Research in Poland. Applied Sciences. 2025; 15(2):861. https://doi.org/10.3390/app15020861

Chicago/Turabian Style

Borucka, Anna, and Sebastian Sobczuk. 2025. "The Use of Machine Learning Methods in Road Safety Research in Poland" Applied Sciences 15, no. 2: 861. https://doi.org/10.3390/app15020861

APA Style

Borucka, A., & Sobczuk, S. (2025). The Use of Machine Learning Methods in Road Safety Research in Poland. Applied Sciences, 15(2), 861. https://doi.org/10.3390/app15020861

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop