# Predicting Road Traffic Collisions Using a Two-Layer Ensemble Machine Learning Algorithm
## 1 Introduction  
Globally, road traffic crashes take the lives of nearly 1.35 million people every year, more than two every minute, with more than nine in ten of all deaths occurring in low- and middle-income countries. Road traffic collisions have become the leading cause of death for people aged 15-29 years, and the World Health Organization (WHO) estimates that crashes will cause another 13 million deaths and 500 million injuries around the world by 2030 if urgent action is not taken [1]. A 2018 WHO research report revealed Kenya as having one of the world's worst collision records, accounting for a fatality rate of 27.8 per 100,000 of the population [2], with the city of Nairobi recording the highest share of the total road crashes in Kenya. In addition, road traffic collisions in Nairobi cause significant losses of human life and economic resources. According to a National Transport and Safety Authority (NTSA) report, 4690 people lost their lives to road collisions between 1 January and 13 December in 2022 [3]. Additionally, the report notes that pedestrians and riders are dying at much higher rates because of car collisions from time to time in Kenya. The WHO recently announced a \"Decade of Action for Road Safety 2021-2030\", setting the target of preventing at least 50% of road traffic deaths and injuries by 2030 [4]. Significant attention is required to minimize road collisions and as a result, research into building prediction models (PMs) and traffic collision prevention is critical to improve road safety policies and to reduce fatalities on roads [5]. Since road traffic collisions are random, traditional techniques, such as logit and probit models, have been widely used to predict these collisions [6]. Although statistical modelshave good mathematical interpretation and provide a better understanding of the role of individual predictor variables, they have some limitations [7].These traditional approaches are built on assumptions, such as requiring a predefined mathematical form, the presence of outliers, and missing values in the dataset. Such inferences may be untrue and can negatively affect the outcome of the prediction model [8]. With advancements in soft computing methods, machine learning techniques have emerged as promising road safety collision research tools to overcome the limitations of statistical methods. In contrast to traditional techniques, machine learning (ML) techniques can manage outliers and missing values in the dataset. To predict road collisions, ML techniques have been applied to primary and secondary road collision datasets for different road networks [9; 10]. Data unavailability in low- and middle-income countries impedes road safety improvements. Access to data is crucial for scientific research on identifying the factors that cause high road risk and assessing the effectiveness of interventions [11]. Our main objective in this study is to develop and evaluate a crash prediction model that can predict road traffic collisions and their patterns. We perform accident analysis by applying a two-layer ensemble stacking method using logistic regression as a meta-classifier, and the four most popular supervised machine learning algorithms (NB, k-NN, DT, and AdaBoost) because of their proven accuracy in this field [12; 13; 14]. Datasets for this study were acquired from a fixed-base driving simulator [15]. The prediction accuracy, precision, recall, and F1-score of each ML technique were compared and measured to highlight the best fit. Our contribution through this paper is the development of a crash prediction model that can predict the outcome of a collision, as this can help emergency centers to estimate the possible impacts, provide better appropriate medical treatment, enable policymakers to formulate better policies for road safety based on evidence, and enable better road traffic safety management. The article is structured as follows. Section 2 focuses on the research methodology and explains data preprocessing, feature selection, and building the ensemble model.