Assessing and mitigating traffic crash risks using interpretable machine learning techniques Authors: Adnan Yousaf, Jianping Wu, Deqing Huang, Muhammad Zahid, Muhammad Faisal Habib, Amjad Pervez, Muhammad Hussain Published: 2026 ABSTRACT AbstractThis study aims to examine factors associated with self-reported crash involvement among drivers in Pakistan using interpretable machine learning (ML) techniques and established driver-behavior instruments. The data used in this study were collected through an Internet-based survey in Pakistan utilizing a self-report questionnaire (cross-sectional design; N:623 drivers). The questionnaire consisted of items related to dangerous (aggressive, risky, and negative emotions), aberrant (errors and violations), and positive driving behaviors, along with demographics and items related to self-reported crashes (Yes/No) over the past three years. Interpretable ML techniques, including Logistic Regression, Categorical Boosting (CatBoost), and eXtreme Gradient Boosting (XGBoost) were employed. Furthermore, to improve the interpretation of ML techniques for self-reported crash risk factors, the Shapley Additive explanation (SHAP) technique was used. The results revealed that aggressive driving and risky driving behaviors, errors, and violations committed while driving, were associated with increased traffic crashes. Prior motorcycle riding experience variable also had a significant association with the occurrence of traffic crashes. Moreover, XGBoost outperformed the CatBoost and Logistic Regression models in terms of predictive performance. XGBoost achieved the highest test accuracy (0.86), compared to CatBoost (0.80) and Logistic Regression (0.73). The study underscores the importance of integrating interpretable ML in traffic safety research. The findings suggest that behavior-oriented road safety interventions such as aggressive and risky driving enforcement, driver education, and risk perception should be prioritized and enhanced. Prior motorcycle-riding experience is important, transition-oriented training should be designed for riders to adapt vehicle characteristics and road usage patterns.Supplementary InformationThe online version contains supplementary material available at 10.1038/s41598-026-52834-8.Keywords: Driving behaviors, SHAP, XGBoost, Traffic crashes, Machine learning, CatBoostSubject terms: Engineering, Mathematics and computing, Risk factors Introduction Governments worldwide are increasingly concerned about road traffic crashes due to their significant impact on both property damage and human casualties, as well as the resulting loss of productivity1. Road traffic crashes are the 12th leading cause of death across all age groups, with a troubling pattern that continues to rise, especially in emerging countries. In fact, individuals aged 18–59 account for 69% of all traffic fatalities. Similarly, men are disproportionately affected, with a fatality rate three times higher than that of women2–4. This issue is particularly concerning in developing countries, where 85% of road fatalities occur, despite these regions only accounting for 52% of the world’s vehicle population5. The higher rate of fatalities in these countries is closely linked to growing populations and rapid economic development, which have intensified motorization and, consequently, increased exposure to traffic-related risks6,7. Pakistan exemplifies this situation, with one of the highest road fatality rates globally, an estimated 27,582 deaths from motor vehicle crashes each year. This translates to an average annual fatality rate of 14.3 per 100,000 people, which, although an improvement over the global average of 17.4, remains alarmingly high compared to developed countries like UK (3 per 100,000) and the US (10 per 100,000)3. The rapid increase in the number of vehicles on Pakistan’s roads, and urbanization, has compounded this issue. Between 2011 and 2020, registered motor vehicles rose by 3.2%, while two-wheelers saw an even steeper increase of 4.2%. However, this growth has not been matched by the development of adequate road infrastructure or effective traffic safety measures, leading to a staggering loss of nearly 49,000 lives8. In Pakistan, careless driving (55%) and driver fatigue (11%) are the leading causes of road crashes9. Over speeding, dangerous driving, risky overtaking, lack of situational awareness, and poor driving habits are the primary causes of careless driving. Owing to Pakistan’s peculiar social and traffic situation, there is an urgent need for precise approaches to assess the factors associated with traffic crashes10–13. Road crashes can be ascribed to a combination of human factors, vehicle issues, and the overall condition of the road environment14. More specifically, human factors, particularly careless driving, are a significant contributor to the high rate of fatalities on Pakistan’s roads. This includes over-speeding, risky overtaking, and poor situational awareness, all of which fall under human behavior. In their simplest form, human factors encompass the individual driver’s behavior and the broader environmental, organizational, and job-related elements that influence driving conduct. These factors, such as fatigue, inexperience, and even stress, directly impact a driver’s health and safety while on the road. Driver behavior greatly affects the control of vehicular motion in traffic scenarios because human factors are directly linked to an individual’s psychological and social nature15. Driver behavior (DB) must be considered when analyzing how people perceive road safety because human-caused factors cause 95% of crashes16,17. Assessing performance, enhancing road safety, and encouraging the development of intelligent and sustainable transportation systems depend heavily on evaluating driver behavior18,19. In general, human driving behavior describes how a driver maneuvers and manages a car in various traffic situations and in reaction to environmental factors19,20. While these insights provide a foundation for understanding the role of driver behavior in road safety, a significant research gap remains. Despite the fact that driver behavior is responsible for the majority of crashes, there is a lack of detailed analysis that specifically addresses the unique socio-economic and traffic conditions in developing countries, such as Pakistan. This study is theoretically grounded in three complementary strands of driver behavior research. The Dula dangerous Driving Index (DDDI) defines Dangerous driving as a multidimensional propensity that includes aggressive driving, risky driving, and negative emotional driving, thus incorporating both affective and deliberately unsafe elements of driving behavior21,22. The Driver Behavior Questionnaire (DBQ) differentiates between inadvertent errors and willful violations, with errors signifying planning-level failures within the wider context of mistakes23. The Positive Driver Behavior Scale (PDBS) highlights respectful, prosocial, and safety-focused actions that are conceptually separate from just exhibiting less inappropriate actions24. Collectively, these frameworks indicate that crash-related consequences may represent not just the existence of dangerous or deviant actions, but also the equilibrium between unsafe and safety-focused inclinations in routine driving18–20,24. This comprehensive perspective offers the theoretical foundation for concurrently analyzing dangerous, aberrant, and positive driving behaviors within the Pakistani environment. Different statistical regression techniques have been frequently utilized in the literature to model driving behaviors and crash involvement, offering valuable insights into relationships between explanatory variables and outcomes. These models are particularly useful for interpretation and hypothesis testing within a theoretically grounded framework25,26 However, they typically rely on predefined functional forms and assumptions regarding linear relationships and error distributions, which may limit their ability to fully capture complex nonlinear patterns and interaction effects often present in behavioral survey data. Econometric models such as mixed logit are widely used for discrete choice analysis and for capturing preference heterogeneity among individuals27. In addition to these approaches, ML methods provide greater flexibility in modeling nonlinear relationships and complex interactions28,29. Therefore, this study adopts a ML framework as a complementary approach to better explore behavioral patterns in the dataset. ML models, particularly deep learning, random forest and gradient boosting methods, have emerged as promising resources in predicting traffic crashes by learning complex non-linear relationships between variables25. Unlike traditional statistical methods, ML approaches do not rely on linear correlations and are more flexible in handling non-parametric data, making them a more suitable choice for analyzing crash risk factors. However, while much of the existing research has focused on enhancing the overall prediction accuracy of these ML models, it is crucial to note that there is a gap in studies that explore the specific significance of individual crash risk factors, particularly when integrated with driver behavior data. This study aims to bridge that gap by applying ML methods to analyze crash risk factors and driver behavior data. For instance, Hasan and, Jalayer30 utilized four ML methods, that is, Random Forest, Light Gradient Boosting Machine (LightGBM), Categorical Boosting (CatBoost), and XGBoost to analyze traffic crashes involving young drivers in New Jersey. The findings indicated that for crash severity prediction, XGBoost outperformed the Random Forest, CatBoost, and Light Gradient Boosting Model (LightGBM) models. Furthermore, sensitivity analysis and Shapley (SHAP) values, were employed to evaluate the influence of the most relevant factors on crashes involving young drivers. Recent crash analyses studies have progressively integrated predictive efficacy with interpretability. Ren, Xu31 utilized XGBoost in conjunction with SHAP to analyze injury severity in highway–rail grade crossing collisions, illustrating the efficacy of explainable machine-learning techniques in finding significant risk factors. Concurrently, other research by Ren and Xu32 has shown that crash-related correlations may differ across contexts and temporal dimensions, as seen by studies employing random-parameter frameworks to examine heterogeneity and temporal instability in injury severity outcomes. These advancements underscore the significance of predicting precision and meticulous interpretation in modeling crash-related phenomena. According to the findings of sensitivity analysis, the severity of the crashes was higher in situations involving many vehicles, angle collisions, collisions at intersections, and dimly illuminated environments Despite the promising results, there remains a need for integrating ML models with detailed driver behavior data, which will be explored further in this study. By combining these methods, the study aims to provide a more comprehensive understanding of the factors contributing to traffic crashes, offering valuable insights for developing targeted interventions. The objective of this study is to evaluate the performance of logistic regression, a baseline interpretable model, and gradient-boosting classifiers (CatBoost, XGBoost) in determining retrospective self- reported crash involvement. To employ SHAP analysis to elucidate the predictions of the top-performing model and rank behavioral correlates in a sample from Pakistan. This study expands upon previous research on driver behavior in Pakistan10–12,17,33–35, which has mainly concentrated on identifying aspects of aberrant driving behavior or analyzing their predictors through traditional statistical models, by incorporating dangerous, aberrant, and positive driving behaviors alongside sociodemographic and driving-history variables within a comprehensive crash-prediction framework. The contributions of this study are threefold. It First evaluates classification performance of XGBoost, CatBoost, and Logistic Regression for predicting self-reported crash involvement (past three years). Self-reported crash data were gathered from Pakistan using a self-reported questionnaire consisting of items related to driving behaviors (aberrant, dangerous and positive) and Socio demographics. Second, the influence of principal contributing elements on model predicted crash involvement classification was assessed utilizing SHAP values30,36. Finally, to comprehend the cumulative impact of these parameters, a SHAP based sensitivity analysis was performed. This study represents the inaugural research in Pakistan utilizing driving behavior data and SHAP analysis to examine traffic crashes, with prior motorbike riding experience identified as a unique predictor. This study represents one of the initial applications in Pakistan that integrates validated driver-behavior instruments with SHAP-based explanations for gradient-boosting models; its contribution is predominantly empirical and contextual rather than methodological innovation. These contributions cumulatively offer a more accurate and contextually relevant knowledge of the relationship between behavioral and experience-based characteristics and model predicted crash involvement in Pakistan. The paper is divided into six sections: Sect. 1 presents the introduction, Sect. 2 represents the data description, Sect. 3 represents the methodology, Sect. 4 represents the model results, Sect. 5 represents the discussion and finally, Sect. 6 presents the conclusions. Methodology Instrument design The data for this study were gathered using a self-report questionnaire survey conducted in Pakistan. Questions about sociodemographic traits, risky driving behaviors, abnormal driving behaviors, and good driving behaviors made up the questionnaire used to gather the data. Participants’ age, gender, education, prior driving and motorcycle riding experience, and other details were all covered in the demographic section. The questionnaire was translated from English to Urdu to better understand the local drivers in Pakistan. We used a methodical process to translate the questionnaire. Four language experts worked together to finish the questionnaire after translating it into Urdu. Five experienced drivers then reviewed the draft to ensure it was clear. Finally, five people who took part in the study tested the translated version to give comments before the questionnaire was completed19,37,38. The participants were also asked to indicate, whether they held a valid driving license. When they drive, do they wear seatbelts? Before they began driving, did they receive any driving instruction? Whether or not, they are satisfied with the licensing mechanism? and within the previous three years, were they engaged in any traffic crashes? In this study the term, traffic crash or crash occurrence is defined as a self-reported involvement in a traffic crash over a period of last three years. This reflects the participants reported crash history instead of police reported incidents in the questionnaire. Dangerous driving behaviors Items pertaining to dangerous driving practices made up the second half of the survey. Data about dangerous driving were gathered using the Dula Dangerous Driving Index (DDDI). The DDDI is a self-report instrument created by Dula and Ballard22 to identify personal biases for unsafe driving. The original scale had 28 items and three components: risky driving (12 items), negative emotions while driving (9 items), and aggressive driving (7 items). Aberrant driving behaviors The third section of the questionnaire consisted of items related to aberrant driving behaviors. An aberrant deriving behavior questionnaire with 30 items was used in this investigation. This questionnaire included 18 items from the original Driver Behavior Questionnaire (DBQ) developed by Reason and, Manstead23, four items from Batool and Carsten35, and eight items designed by the authors based on local driving factors. Positive driving behaviors The last section consisted of items related to positive driving behaviors. Positive driving behaviors were measured using a self-report instrument originally developed as an addition to the DBQ by Ozkan and Lajunen24 in a study involving Turkish drivers. The original 13 item PDBS was used in the study to collect data. Respondents rated the frequency of each item on a six-point Likert scale ranging from 1 (“never”) to 6 (“very often”). A meticulous development approach was implemented to guarantee the validity and reliability of the questionnaire. The instrument utilized existing scales, including the DDDI and DBQ, both of which have been verified in prior studies21,22,24,39,40. Instruments were modified for the local context, and additional things were incorporated to represent the peculiar driving conditions in Pakistan. The integration of standardized and bespoke items enhances the survey’s robustness while accommodating local driving variables. Moreover, employing established scales guarantees that the instrument possesses a substantial level of content validity, as it is based on thoroughly validated frameworks of driver behavior. The Likert scale employed to assess behavioral frequency reliably captures participant responses, yielding both quantitative and qualitative insights into driving tendencies. Furthermore, pilot testing of the instrument was performed to enhance the items and guarantee clarity and suitability for the target demographic. This validation and refinement procedure enhances the survey’s overall reliability and its capacity to appropriately assess the constructs of interest. This questionnaire integrates established measures with locally tailored information, offering a complete and valid instrument for examining the factors that affect driving behaviors in Pakistan. The instrument’s rigor guarantees that the study’s findings will provide significant insights into road safety. A specimen of the questionnaire utilized in this investigation is included as Supplementary Material (Appendix/Supplementary File S1) to enhance transparency and reproducibility. Data collection For data collection a Google form was created, and the links were shared through social media throughout the country. All the methods for data collection were performed in accordance with the relevant guidelines and regulations and in compliance with the Declaration of Helsinki. Every participant in this questionnaire survey gave their informed consent in writing. The goal of the study, the fact that participation was voluntary, and the fact that withdrawal was possible at any moment without repercussions were all explained to the participants. A total of 796 samples were collected, which consisted of drivers aged 18 years and above, belonging to different parts of the country. Initial data screening and sorting were performed using SPSS version 26.0 software. Data screening resulted in 732 valid responses from vehicle drivers and motorcycle riders. For this study only the data for vehicle drivers was used so the final data set used in data analysis consists of 623 valid responses. The descriptive statistics of the sample are summarized in Table 1. Table 1Descriptive statistics of the Variables used in the study (N:623).VariablesCategoriesFrequency (%age)Age18–24 years236 (37.87%)25–34 years130 (20.85%)35–44 years107 (17.17%)45–54 years78 (12.51%)55–64 years60 (9.63%)Above 65 years12 (1.92%)GenderMale506 (81.2%)Female117 (18.8%)Driving Experience< 1 year30 (4.8%)1–5 years228 (36.6%)6–10 years175 (28.1)11–15 years86 (13.8%)16–20 years54 (8.7%)> 20 years50 (8%)Motor cycle Riding ExperienceNo experience180 (28.8%)1–4 years136 (21.82%)5–8 years117 (18.78%)9–12 years51 (8.18%)13–15 years53 (8.5%)16–20 years41 (6.5%)> 20 years45 (7.2%)Driving Licenseyes467 (74.95%)No156 (25.05%)Driving TrainingFrom the Traffic Police driving school41 (6.5%)From a private driving school104 (16.69%)From a friend152 (24.39%)From a family member/relative326 (52.33%)Seat Belt UsageYes307 (49.28%)No316 (50.72%)Self-reported CrashesYes345(55.4%)No278(44.6%) Descriptive statistics of the Variables used in the study (N:623). Factor structure Principal Component Analysis (PCA) with varimax rotation was conducted to evaluate the underlying structure of the questionnaire items in the current dataset, aiming for a clearer and more interpretable factor solution. Before extraction, the appropriateness of the data for factor analysis was validated by the Kaiser-Meyer-Olkin (KMO) measure of sample adequacy and Bartlett’s test of sphericity. Components were kept according to eigenvalues over 1.0, analysis of the scree plot, and conceptual clarity. Items exhibiting sufficient factor loadings (> 0.3) were categorized according to their respective components, and the internal consistency of the retained factors was subsequently assessed using Cronbach’s alpha. This approach was employed to validate the dimensional structure of the selected scales prior to conducting the subsequent analysis. Analytical method The analytical framework of the paper is presented in Fig. 1 below; Analytical framework of paper. eXtreme gradient boosting (XGBoost) Friedman’s proposed gradient boosted approach forms the basis upon which the XGBoost ensemble algorithm was developed41. In 2016, the gradient boosting algorithm was modified by Chen and Guestrin and renamed as XGBoost42. Classification trees are the foundation of both ensemble techniques: XGBoost and Gradient Boosting (GB). The majority of tree-based ensemble algorithms used in reality usually consist of several trees that are joined together to improve classification accuracy. For ensemble models, this means that the sum of the classification scores for samples from each tree (x) can be used to describe a common model (ŷ). Concurrently training a series of classification and regression trees (CARTs), XGBoost aggregates the scores from each CART to arrive at a final prediction. The general equation of the gradient boosting model is shown in Eq. 1. Where T is the number of trees and F is the space for all trees. Equation 1 was further optimized for the objective function, The first part is the loss function that distinguishes between the prediction (ŷi) and target (yi). The next section serves as regularization, controlling the complexity of the model and avoiding overfitting. Compared with Gradient Boosting (GB), which adds an extra incremental regularization term for improved control, XGBoost depends only on the learning rate (L) to reduce the impact of each subsequent tree. In Eq. 3, “Cq(x)2j” indicates the score for the jth leaf, while “t” indicates the total number of leaves. Regularization parameters λ and γ were included. Moreover, XGBoost is distinguished from other ML algorithms as a refined version of Gradient Boosting (GB), which is well-known for its precision, effectiveness, and simple implementation. These benefits enable XGBoost to produce better results than the traditional gradient boosted decision trees (GBDT). To increase results and accuracy, we used grid search for hyperparameter tuning in XGBoost. Table 3 shows the optimum hyperparameter values used to predict traffic crashes. Table 3Classification performance metrics for ML models.ModelsAccuracyF-1 scorePrecisionRecallTrainTestTrainTestTrainTestTrainTestXGBoost0.960.860.960.850.9600.8510.9540.850CatBoost0.810.800.800.800.8080.8130.8050.807Logistic Regression0.810.810.800.8120.8080.8120.8010.803 Classification performance metrics for ML models. Table 2XGBoost Optimized Hyperparameters.ParametersDescriptionValueRangeLearning rateTo reduce the gradient step0.10.01–0.2Maximum depthDepth of Tree42–8No. of estimatorConstructing the maximum number of trees possible400200–600Loss functionEvaluation metric to employ in training for a binary class targetBinary class XGBoost Optimized Hyperparameters. SHAP Values The importance of interpretability and explainability of models in ML applications has not received sufficient attention in the field of traffic safety research. Prior research has ignored the critical component of model interpretability in favor of enhancing model performance and contrasting it with other models. Furthermore, to inform and direct traffic mitigation initiatives, it is essential to assess the effects of various risk factors, and their combined impact. To fill this void, game theory-based SHAP (SHapley Additive exPlanations) presents a fresh approach to ML model interpretation36. To measure the effect of individual features on the final model output, we used the SHAP values assigned to each feature as a starting point, as shown in Eq. 4. In Eq. θ, q is the explanation model, M represents the number of features in the model, θj denotes the SHAP value for the jth feature, sj if the feature j is present = 1, otherwise = 0 and θ o is the model constant. The SHAP value linked to feature j is ascertained through a comparison of the model output, whether or not it has the feature included, as shown in the Eq. 5. Here, ’F’ represents the subset of features included in the model, and ’R refers to the complete set of features. The model output with and without feature j included are denoted by the terms ν (F ∪ j) and ν(F), respectively36. A feature with a positive SHAP value indicates that the model’s results are positively influenced, potentially pointing to a tendency towards more crashes. On the other hand, a negative SHAP value suggests that the model’s results will be negatively impacted, potentially leading to no crash. Results Questionnaire validation The data were analyzed to determine the factor structure of each questionnaire used to collect the data. Principal Component Analysis (PCA) with varimax rotation was performed for the three driver behavior questionnaires. PCA revealed a three-factor solution for the DDDI; each factor was named aggressive driving (Any behavior by a driver aimed at inflicting physical or psychological harm on others22, risky driving (Driving behaviors characterized by a lack of intent to hurt others, frequently driven by indifference or animosity22 and negative emotional driving (operating a vehicle while experiencing emotions of impatience, frustration, provocation, and wrath, such as losing one’s temper or deeming the behavior of other drivers as inappropriate or foolish22. The PCA for DBQ also revealed a three-factor solution, which were named errors, violations, and mistakes depending upon the item loading against each factor. The term “error” denotes any instance where a predetermined sequence of cognitive or physical acts fails to yield the intended outcome and cannot be attributed to the influence of a random factor23. Whereas Mistakes (a sub dimension of errors) are identified as ineffective strategies or poor judgment expected by execution and occur when a driver performs an action incorrectly. The occurrence of mistakes is frequently referred to as a failure in planning23. Violations are intentional deviations from practices deemed essential for the safe operation of a potentially dangerous system, yet they may not be inherently objectionable23. The PCA for the PDBS revealed only a single-factor solution, which was named positive driving. Similar PCA analysis findings have been published in the authors’ earlier papers, including19,29,30. All factors obtained for each questionnaire were checked for internal consistency and reliability by determining Cronbach’s alpha reliability coefficients. The reliability coefficient values for each factor were within the standards of Cronbach’s alpha35. The details of the factors obtained for each questionnaire, their alpha coefficients, and the scales on which these factors were measured are reported in supplementary Table 1. Machine learning model’s evaluation Standard performance criteria were used to assess the efficacy of various techniques. These metrics included the F-1 score, precision, recall, accuracy, confusion matrices and ROC–AUC metrics. In this study, the target variable, that is, the dependent variable (traffic crash), is a variable with a binary outcome (yes and no). Three ML techniques XGBoost, Logistic Regression36, and CatBoost37, were implemented using the Python analytic platform. Moreover, Sensitivity analysis was performed using SHAP (SHapley Additive exPlanations) values based on the XGBoost model to assess the global importance of predictors and examine the precise impact of driving behavior elements that lead to traffic crashes. Based on a variety of behavioral and demographic characteristics, these measures measure how well each model differentiates between drivers who were involved in crashes and those who were not. To evaluate generalization capacity, the dataset was divided into training (70%) and testing (30%) subsets. Moreover, the crash involvement variable shows a relatively balanced distribution, with 345 crash cases (55%) and 278 non-crash cases (45%), corresponding to a class ratio of approximately 1.24:1. Consequently, class imbalance handling techniques were not applied to preserve the original data distribution. XGBoost continuously outperformed the competition in every metric, as shown in Table 3. These results imply that XGBoost outperforms the other models in capturing intricate non-linear correlations in the data. For XGBoost, the performance difference between training and testing scores was small. The difference between training and testing accuracy is expected for ensemble learning algorithms and remains within an acceptable range, indicating that the model captures meaningful patterns without significant overfitting. In addition to overall accuracy, the model performance was evaluated using precision, recall, F1-score, and ROC–AUC metrics. The results demonstrate strong classification performance across both classes. For the non-crash class, the model achieved a precision of 0.80 and a recall of 0.86, while for the crash class, it achieved a precision of 0.89 and a recall of 0.84, as depicted in Fig. 2. Moreover, the ROC–AUC results further confirm the model’s ability to effectively distinguish between crash and non-crash cases across different decision thresholds, as shown in Figs. 3, 4, 5 and 6. Additional information about each model’s classification behavior can be found in the confusion matrices (Table 4). While keeping false positives (FP) and false negatives (FN) comparatively low, XGBoost shows a greater number of true positives (TP) and true negatives (TN). This suggests a strong capacity to accurately identify drivers who were involved in crashes as well as those who were not. Precision, recall and F1 score for each model. ROC curve XGBoost. ROC curve logistic regression. ROC curve CatBoost. ROC curve comparison of models. Table 4Confusion Matrix results for the three ML models.ModelsTrue Negative (TN)False Positive (FP)False Negative (FN)True Positive (TP)XGBoost7291888CatBoost71101888Logistic Regression58232878 Confusion Matrix results for the three ML models. Importance of risk factors In XGBoost, SHAP values quantify each feature’s contribution to the model’s prediction, showing whether a feature improves or degrades the expected result. Clear insight into the model’s decision-making process and feature relevance is provided by positive SHAP values, which increase the prediction while negative values decrease it. Features are ranked according to their average influence on the model’s output in the SHAP summary display (Fig. 7). The most significant predictors of crash involvement include prior motorcycle riding experience (mean absolute SHAP value 0.80), positive driving behaviors (mean absolute SHAP value 0.57), traffic violations and driving errors, aggressive and dangerous driving practices, driver training, and overall driving experience. Summary plot for SHAP values for binary class XGBoost model. Drivers with a lot of motorcycle riding experience, especially those with more than eight years of experience, are more prone to be involved in crash, according to high SHAP values for motorcycle riding experience. This may reflect overconfidence or improper use of reflexes unique to motorcycles when operating a car, like quick lane changes or inadequate vehicle dynamics adaptation. Significant SHAP contributions were also obtained from aggressive, dangerous, and abnormal driving behaviors. On the other hand, Positive driving traits, such as being cautious, following the law, and being courteous, had negative SHAP values, indicating a negative association with predicted crash involvement. Interestingly, the SHAP influence of demographic variables such as gender, seatbelt use, license status, and education were negligible, indicating that behavioral factors predominate in predictive value. These findings are further supported by class-specific SHAP value distributions (Fig. 8). High values of risk-related variables cause predictions to lean toward positive classification in the crash-involved class as shown in Fig. 6. On the other hand, high values of low-risk behavioral traits and positive driving behaviors in the non-involved class direct predictions in the direction of the negative class. Summary plot individual effect of crashes (yes) for SHAP value for XGBoost model. Main and Interaction effects In ML analysis, main and interaction effect plots are frequently employed, particularly when analyzing and illustrating the influence of factors on model predictions. The main effect plots show how one variable can directly impact a model’s output or prediction while holding other variables constant. Utilizing line plots and other visualization approaches, the plot illustrates the relationship between the variable of interest and the anticipated response. Drivers with more than eight years of motorcycle riding experience are more prone to crashes than those with less or no experience. The most significant positive contributions were noted for respondents with 13–16 years of motorcycle riding experience, exhibiting SHAP contributions of roughly + 3.2, followed by those with 17–20 years and beyond 20 years of experience, both around + 2.5. Conversely, 1–4 years of motorcycling experience correlated with a negative impact of around − 1.2, but 5–8 years of experience and no experience were nearly neutral (Fig. 9). This reflects overconfidence in their skills, which could cause them to engage in unsafe driving practices like speeding or making abrupt corners. Lane splitting and other motorcycle- specific skills do not necessarily translate to safe car driving, which increases the risk of collisions30. Drivers who rarely or never practice positive driving behaviors are more prone to crashes, according to the plot for positive driving behavior (Fig. 10). These activities, such as disobeying safety regulations or taking risks, increase the likelihood of crashes. On the other hand, because these activities encourage safer driving, drivers who regularly practice positive driving behaviors (“always” or “often”) typically have a lower crash risk. These outcomes are consistent with Singh and Kathuria’s research41. Main effects plot for motorcycle riding experience and traffic crashes (yes). Main effects plot of positive driving behaviors and traffic crashes (Yes). Drivers who “always” or “often” participate in aggressive driving behaviors have an increased likelihood of being involved in traffic crashes than those who “ever” or “rarely” do, according to the main effect plot (Fig. 11). There is mixed crash participation among those who claim “sometimes” aggressive behavior. Aggressive behaviors such as sudden lane change and impulsive maneuvers were associated with higher predicted crash involvement. These results are consistent with those published by Yousaf and Wu30. A similar pattern is shown for risky driving practices. For Risky Driving (Fig. 12), the contribution varied from roughly − 0.3 for never to + 1.1 for always, signifying a more pronounced upward change than that recorded for aggressive driving. The low crash involvement of drivers who never or infrequently drive recklessly supports the substantial link between regular dangerous behavior and a higher probability of crash involvement. Main effects plot of aggressive driving behaviors and traffic crashes (Yes). Main effects plot of risky driving behaviors and traffic crashes (Yes). In the case of Violations (Fig. 13), the term “always” was linked to a positive contribution of approximately + 0.9, whereas “rarely” and “never” were connected with negative contributions of about − 0.4 and − 0.2, respectively. Drivers who “always” or “often” commit violations are more prone to crashes than those who never do. Drivers committing violations “sometimes” have conflicting outcomes, occasionally getting into crashes and other times not. Regular violations, like speeding or running red lights, cut reaction times and make junctions riskier, which increases the severity of crashes. According to Hussain, Shi11 and Hussain and Shi10, the crash risk increases with the frequency of these violations. Main effects plot of violations and traffic crashes (Yes). The relationship between motorcycle riding experience and risky driving in relation to crash involvement is depicted in Fig. 14. The highest crash probability is found among drivers who regularly participate in risky behaviors and who either have no motorcycle riding experience or have more than 20 years of experience. Individuals with up to 20 years of experience who engage in risky behaviors regularly are also prone to crash risk. Interestingly, while engaging in unsafe activities, certain inexperienced drivers without any riding experience seem less associated with crash, maybe due to limited exposure. On the other hand, highly skilled riders could exhibit complacency or overconfidence, resulting in less caution and riskier choices. These results confirm the findings of Yousaf and Wu30 by indicating that both inexperience and excessive experience, when paired with risky driving practices, raise the likelihood of crashes. SHAP interaction effects plot of Risky driving and traffic crashes (Yes). Untrained drivers who infrequently or irregularly exercise safe driving have a higher crash association than drivers who receive training from traffic police or accredited schools and who regularly practice safe driving, as Fig. 15 illustrates. Formal training was associated with lower predicted crash involvement among drivers who also reported more frequent safe driving practices. As a result, drivers who received this training and consistently engage in safe driving practices had the lowest crash involvement rates, underscoring the importance of recognized training in fostering long-lasting safe driving habits. SHAP interaction effects plot of driving training and traffic crashes (Yes). Drivers without formal training who occasionally participate in risky behaviors had higher crash rates, as seen in Fig. 16, highlighting how a lack of structured instruction hinders hazard recognition and response. Remarkably, even traffic police school-trained drivers show high likelihood of engaging in risky activity, suggesting that behavioral qualities (such as overconfidence and risk tolerance) can supersede learned information. Taken together these interaction patterns suggests that crash involvement may be associated with both training background and risk related behaviors. Informal family-trained drivers also have higher probability of crash involvement when they participate in risky behaviors, suggesting that such training may not thoroughly emphasize on safety and may even reinforce dangerous behaviors. Similarly, friend-based training produces uneven results; crash involvement varies according to the friend’s level of experience and instruction, and peer pressure may minimize hazards, leading to uneven safety performance. SHAP interaction effects plot of driving training and traffic crashes (Yes). Whether they are utter beginners or have been riding motorcycles for over 20 years, untrained drivers face a higher crash risk, as shown in Fig. 17. This is probably because full inexperience and overconfidence jeopardize safe vehicle control without formal training. Additionally, those who receive training from family members with more than eight years of motorcycle experience are also involved in more crashes, indicating that informal training is ineffective in teaching car-specific safety skills or breaking long-standing motorcycle behaviors. Family-based training was linked to positive or almost positive contributions, often ranging from 0.00 to 0.04. This pattern was most pronounced when training was analyzed in conjunction with Positive Driving, Risky Driving, and motorcycle riding experience. SHAP interaction effects plot of driving training and traffic crashes (Yes). According to Fig. 18, drivers with less than 1 year and 1–5 years of driving experience exhibited favorable SHAP contributions, while those with 15–20 years and over 20 years of driving experience typically demonstrated negative contributions. The engagement with Positive driving indicates that the correlation between increased experience and reduced projected crash involvement was most pronounced when coupled with more frequent positive driving behaviors. This is probably because they were overconfident initially, their novelty faded, and they used safe habits inconsistently. Young inexperienced (less than one year) drivers have a higher propensity of being involved in crashes because they lack skills and instincts required to avoid risky situations without regular driving practice. Conversely, drivers with more than 20 years of experience who consistently exhibit positive behaviors have the lowest crash probabilities, which is indicative of their proactive decision-making, elevated risk awareness, and deeply embedded safety habits. SHAP interaction effects plot of driving experience and traffic crashes (Yes). Discussion The SHAP-based analysis of the XGBoost model revealed that driver behavior variables dominated crash risk. In particular, high levels of aggressive and risky driving behaviors (e.g. speeding, tailgating, or other forms of intimidation) along with aberrant behaviors (self-reported errors and violations) were the strongest positive contributors to predicted crash involvement. In contrast, positive driving behaviors (courteous, attentive actions) had a protective effect on crashes. For example, our findings mirror those of Yousaf and Wu19, who found that aggressive/risky driving significantly increased crash likelihood in both Pakistan and China, while positive behaviors predicted crashes negatively. Crucially, motorcycle riding experience emerged as a notable risk factor: drivers with extensive past motorcycle experience showed higher crash risk in our model. This counterintuitive result is consistent with recent regional work. Yousaf and Wu38 report that each unit increase in motorcycle experience raised crash probability by 67%, and Hussain, Shi11 observed that more riding experience led to greater engagement in risky riding and distracted violations, which in turn elevated crash risk Finally, the SHAP results indicated that formal driving training or experience had relatively modest effects on crash prediction. This finding indicates that conventional training, as currently delivered, may not be sufficient to counteract the risks posed by aberrant behaviors. Despite the model revealed distinct behavioral correlates of self-reported crash involvement, additional explanations must be recognized. The correlation between prior motorcycle-riding experience and elevated model-predicted crash involvement may indicate behavioral carryover, increased exposure, or other unquantified variances in driving history34,43. Likewise, the limited impact of formal training may indicate discrepancies in instruction quality rather than an absence of advantage10,44, whereas the reduced influence of positive driving behavior may be affected by self-report bias or restricted variability24,33 Consequently, these findings should be understood as theory-driven correlations within the established paradigm, rather than conclusive proof of fundamental mechanisms. In comparison to previous research undertaken in Pakistan, the current study provides a unique empirical and substantive addition. Previous research conducted in Pakistan has predominantly concentrated on explaining local aspects of aberrant driving behavior, evaluating the impact of licensing, training, and motorcycle-riding experience on such behaviors, or examining crash outcomes through traditional statistical models and official datasets10,12,17,33–35,43. This study integrates many validated behavior-related constructs i.e., dangerous driving, aberrant driving, and positive driving behaviors, with demographic and experiential characteristics within a unified prediction framework based on self-reported crash participation. Furthermore, instead of solely depending on coefficient-based interpretation, it evaluates three classification models and employs SHAP to illustrate the contribution of features to model predictions30,36,45. This facilitates the connection between behavioral road-safety research and interpretable ML in Pakistan, while emphasizing prior motorcycle-riding experience as a contextually significant predictor in a context where two-wheelers are widely used38,43. These findings align closely with prior studies in Pakistan and the region. Hussain, Shi11 showed that Pakistani drivers lacking proper training or licensing were more prone to unsafe driving patterns. They further found that distracted violations and licensing status were the key predictors of crash involvement11. In our study, the prominence of violations and errors concurs with this: SHAP identified distracted and intentional violations as major risk contributors. Similarly, Hussain, Shi11 linked motorcycle experience indirectly to crashes via increased distracted violations. Our observation that experienced motorcyclists may carry over dangerous habits into car driving is in line with their result11 that distracted violations dramatically raise crash odds (by 54% per unit increase). Yousaf and Wu19 recent cross-cultural survey also found that Pakistani drivers reported higher aggressive and risky driving and had higher crash involvement than Chinese drivers supporting our model’s emphasis on dangerous driving styles. Overall, the strong influence of human factors is consistent with the literature: earlier work notes that 95% of crashes are attributed to human error and behavior11,16,19 and that drivers contribute to over 90% of traffic crashes11. Our results support the idea that, in Pakistan as in other countries, driver behavior is the main factor influencing crash risk. The prominence of aggression and violations implies that road safety policy in Pakistan should target these behaviors. This could include stricter enforcement against speeding, tailgating, unsafe overtaking, and public campaigns to curb road rage. Our findings (similar to those of Yousaf and Wu19 suggest that measures like demerit-point systems or higher fines for aggressive violations may be particularly effective. Likewise, positive driving habits deserve emphasis: drivers who “pay attention and show courtesy” appear markedly safer19,37, so training and awareness programs should encourage these habits. Given the limited crash impact of existing training, policymakers might consider revamping driver education, for example, incorporating computer-based hazard perception and anticipation modules, which have shown crash-reduction promise in controlled studies46. Policymakers should ensure that motorcyclists receive targeted education about how risky riding behaviors transfer to car driving. Licensing protocols could include more rigorous testing of safe riding/driving skills for those with extensive motorcycle history. Similarly, campaigns could focus on two-wheeler safety and its influence on driving habits. As Hussain, Shi11 point out, Pakistan’s weak enforcement and lack of separate motorcycle lanes mean riders often develop aggressive habits addressing these systemic issues could mitigate the “carry-over” effect into car crashes. A few findings were counterintuitive. Most notably, we expected more overall driving experience or training to lower the crash risk. Instead, the data showed little protective effect. This aligns with the global training literature44 but remains unsettling: it suggests that current training in Pakistan may not effectively change risky attitudes. The elevated risk among veteran motorcyclists was also surprising. While some studies assume more experience yields safer drivers, our analysis (and related work38 indicates that certain experiences can engrain bad habits. Additionally, the relatively small influence of positive behaviors was unexpected; although they were protective, their effect size was weaker than that of aggressive behaviors. This may reflect a ceiling effect (most drivers endorse some positive habits) or suggest that promoting safe behaviors, while valuable, will have less immediate impact than curbing dangerous ones. In summary, this interpretable ML approach confirms that driver behavior is paramount in crash causation, a conclusion strongly supported by the literature11,19. The key determinants we identified (aggression, violations, rider experience) are largely consistent with existing studies, but using SHAP provides new clarity on their relative importance. This contributes to theory by quantitatively ranking the factors and, in practice by suggesting where interventions can be most effective. Ultimately, embedding these insights into policy (e.g. targeted enforcement, improved licensing, enhanced training) could help reduce Pakistan’s high crash burden. Our findings also lay the groundwork for more advanced research, for instance, using instrumented vehicles or administrative crash data to validate and refine these behavioral risk models. Conclusions The results of this study demonstrate the effectiveness of combining interpretable machine learning techniques with driver behavior data to examine self-reported crash involvement among drivers in Pakistan. Among the three evaluated models, XGBoost exhibited superior predictive performance on the study’s dataset, outperforming both CatBoost and Logistic Regression. SHAP-based analysis showed that aggressive driving, risky driving, DBQ-related violations, error-related behaviors, and having ridden a motorcycle before were the most important factors that led to model-predicted crash involvement. On the other hand, in the built model, positive driving behaviors, driving experience, and formal training had only small or negative effects. The findings indicate that, within this dataset, behavior-related variables exerted greater influence on crash prediction than various demographic characteristics. These results support the need for behavior-based road safety interventions in Pakistan, which should include improved enforcement against dangerous, aberrant, and positive driving behaviors, as well as advancements in driver education and training programs that focus on risk perception, self-regulation, and safe decision-making. The importance of previous motorcycle-riding experience also points towards the potential benefits of transition-oriented training for drivers transitioning from motorcycles to car driving, which could help them adapt to the different characteristics of the vehicle and road use behaviors. This research contributes to the existing road safety literature in Pakistan by incorporating dangerous, aberrant, and positive driving behaviors in a comparable and interpretable ML framework. However, as SHAP does not reveal real causation, these results should be considered as related to model-predicted crash participation, rather than real-world crashes, where these variables are directly causing or inhibiting crashes. Future research should verify these trends with a larger and more heterogeneous sample size, including commercial and heavy vehicle drivers, as well as possible self-reported and actual crash records, where feasible. In addition to some significant results, this study has a few limitations. The online administration of the survey may have excluded people deprived of reliable internet connection, thereby resulting in coverage bias and diminishing sample representativeness. The distribution of the questionnaire via social media and the voluntary aspect of participation may have resulted in self-selection bias, leading to increased involvement from respondents who were more digitally connected or more eager to participate in the survey. Moreover, crash involvement was assessed by individuals’ self-reported histories in the questionnaire and was not restricted to severe or officially recorded instances, which must be considered when interpreting the stated prevalence of crashes. This may partially elucidate the comparatively elevated crash prevalence in the sample (54.73%), which may not represent the broader driving population. The increased frequency of crashes may affect model performance indicators, like precision and recall, which are sensitive to class distribution. While the sample size of 623 drivers is enough for the analyses performed, it constrains the generalizability of the results. Subsequent research with larger and more representative samples might enhance the validation of these findings. The sample is primarily male (81.2%). While this may represent local driving demographics, it constrains inferences regarding female drivers; gender-based subgroup analyses may lack sufficient power. Consequently, the findings should be extrapolated to female drivers with caution and verified in populations with greater female representation. Another limitation is the lack of temporal precedence. Psychological and behavioral variables were evaluated during the survey, while crash involvement was reported retrospectively for three years. The findings are relationships with past self-reported crash involvement, not causative effects or crash risk prediction. Future studies should concentrate on bigger datasets, such as drivers of trucks and commercial vehicles, to enhance model accuracy and further strengthen our understanding of the risk variables for traffic crashes. Supplementary Information Below is the link to the electronic supplementary material. Supplementary Material 1 Author contributions “Conceptualization, A. Yousaf.; Wu. J. and Z. Muhammad.; Methodology, A. Yousaf.; Wu. J. and Z. Muhammad.; Software, A. Yousaf.; F. Habib. and Z. Muhammad.; Validation, A. Yousaf.; M. Hussain; F. Habib. and Z. Muhammad.; Formal analysis, A. Yousaf.; M. Hussain; Faisal. Habib. and Z. Muhammad.; Investigation, A. Yousaf. and Z. Muhammad.; Resources, A. Yousaf.; Wu. J. and Z. Muhammad; Data curation, A. Yousaf.; Faisal. Habib. and Z. Muhammad.; Writing—original draft preparation, A. Yousaf.; and Wu. J.; Writing—review and editing, A. Yousaf.; Wu. J.; M. Hussain; F. Habib.; Z. Muhammad; A. Pervez. and D. Huang; Visualization, A. Yousaf.; Wu. J. and Z. Muhammad.; Supervision, Wu. J. and D. Huang; Project administration, Wu. J. and D. Huang. All authors read and agreed to the published version of the manuscript.” Funding This study was supported by Fundamental Research Funds for the Central Universities Project No: 2682025CX086, SouthWest Jiaotong University (受中央高校基本科研业务费资助 项目编号: 2682025CX086, 西南交通大学). Data availability Data will be made available upon request from the corresponding author. Declarations Competing interests The authors declare no competing interests. Ethical approval The study was approved by the Ethics committee of SouthWest Jiaotong University (Approval No SWJTU-2501-QT (002)). Informed consent All participants were informed about the purpose of study, and informed consent was obtained from all the subjects involved in the study. All the methods were performed in accordance with the relevant guidelines and regulations and in compliance with the declaration of Helsinki. Footnotes Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. References Associated Data Supplementary Materials Supplementary Material 1 Data Availability Statement Data will be made available upon request from the corresponding author.