## 3 Proposed Methodology
### Generalized Machine Learning Hurdle Model
In a generalized two-stage framework for crash frequency analysis, the objective is to employ distinct machine learning models for both stages, ensuring that each stage is tailored to the specific aspect of the crash frequency distribution that it is intended to model. Figure 1 illustrates the conceptual framework of the generalized machine learning-based hurdle model for crash frequency analysis. The first stage is a binary classification model that predicts the likelihood of a road segment experiencing any crashes. The outcome of this model is binary: either a crash occurs (at least one), or it does not (zero crashes). Advanced machine learning classifiers such as logistic regression, support vector machines, boosting tree machines, or neural networks can be used in this stage, depending on the complexity of the data and the non-linear relationships between the features. The output of the binary classification model denoted \(\phi(x)\) can be predicted from the training data. Before building the model, it is necessary to create a binary outcome where all positive counts are transformed into one class (coded as \"1\", for example) and zero counts are another class (coded as \"0\", for example). This transformation simplifies the target variable to a binary outcome suitable for classification algorithms. Following the classification stage, the second stage employs a machine learning regressor to predict the frequency of crashes, specifically focusing on segments where at least one crash has occurred. This regressor might be a gradient-boosting machine, a generalized additive model, a neural network-based regression model, or any machine learning model designed for count data, which can effectively process the intrinsic complexities of non-zero crash counts. The regression model, denoted \(\mu(x)\), can be estimated from training data using positive counts only. Based on the above, the expected crash frequency for a given road segment, considering all segments, integrates the outcomes from both stages, expressed as follows:  
\[\mathrm{E}[\mathrm{Y}\mid\mathrm{X}]=\hat{\phi}(x)\cdot\hat{\mu}(x) \tag{4}\]  
where \(\hat{\phi}(x)\) is the probability of the road segment experiencing any crashes, obtained from the machine learning classifier \(\phi(x)\), and \(\hat{\mu}(x)\) is the expected number of crashes given that the segment has already surpassed the hurdle of zero crashes obtained from the machine learning regressor \(\mu(x)\). By employing separate models, the framework accommodates different data distributions and relationships within the two stages and allows for capturing the complex, non-linear relationships in the data, thus providing a robust prediction mechanism for crash frequency. This dual-model approach may significantly enhance the understanding and prediction of crash frequencies, thereby informing more effective road safety strategies. Figure 1: Conceptual framework of the generalized machine learning-based hurdle model. The following steps outline the methodological framework applied in this study to develop and validate a machine learning-based hurdle model for crash frequency analysis, as illustrated in Figure 1:  
**Step 1: Data Preprocessing**  
Data preprocessing is essential for ensuring that the dataset is clean, reliable, and suitable for machine learning analysis. This step includes the following:  
* **Data Cleaning**: Removing redundant, erroneous, or inconsistent entries that could bias the analysis. For example, duplicate records or missing values are identified and handled to ensure data quality. * **Feature Engineering**: Creating or transforming variables to better capture underlying patterns in the data. This may involve modifying road segment attributes or combining features to enhance the dataset's predictive power. * **Variable Transformation**: Converting categorical variables into numerical representations if needed, and applying transformations to ensure compatibility with machine learning algorithms.