# Integrating Machine Learning Techniques for Enhanced Safety and Crime Analysis in Maryland
## 3 Methodology
### Model Comparisons and Performances  
To robustly evaluate model performance and guard against overfitting, multiple train-test splits were employed. In addition to a conventional 80/20 split, we assessed each model under 70/30, 75/25, 80/20, and 85/15 train-test splits. This approach provides insight into model robustness across varying training set sizes and data partitions. By comparing performance across these splits, we can identify models that consistently perform well (high average R\({}^{2}\) and low RMSE) and that exhibit low variance in metrics, indicating stable generalization. Table 4 summarizes the mean R\({}^{2}\) and RMSE achieved by each model across the four splits, along with the variance of these metrics as an indicator of stability. The performance of various models is shown across different train-test splits; the values are the mean R\({}^{2}\) and RMSE across the 70/30, 75/25, 80/20, and 85/15 splits. The variance of each metric across the splits is included to illustrate model stability (lower variance indicates more consistent performance across the different data splits). As shown in Table 5 and Figure 8, the linear models (ordinary linear regression and its regularized variants) yielded comparatively poor performance. Their average R\({}^{2}\) scores remain modest (only 0.45-0.58) with relatively high RMSE values (on the order of 13-17 in error). In particular, lasso regression underperformed the most noticeably, achieving an R\({}^{2}\) of just 0.45--markedly lower than the ridge model or OLS--and an RMSE of around 17.5, indicating substantial prediction errors. The lasso model's aggressive feature selection (driving many coefficients to zero) likely led to underfitting; even with its best-tuned regularization parameter (\(\alpha\approx 0.1\), see Table 6), it failed to capture enough of the variance in the data. In contrast, ridge regression (with a moderate \(\alpha\approx 0.5\)) retained more predictive features and attained slightly higher accuracy (R\({}^{2}\approx 0.58\)), although it, too, fell short of the more complex models' performance figures. Overall, the linear approaches struggled to model the complex relationships in the dataset, as evidenced by their lower R\({}^{2}\) and higher RMSE values. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **R\({}^{2}\) (Mean)** & **R\({}^{2}\) Variance** & **RMSE (Mean)** & **RMSE Variance** \\ \hline Linear Regression & 0.50 & 0.010 & 15.0 & 2.25 \\ Ridge Regression & 0.58 & 0.008 & 13.2 & 1.89 \\ Lasso Regression & 0.45 & 0.012 & 17.5 & 3.10 \\ Random Forest & 0.85 & 0.003 & 8.4 & 0.64 \\ Gradient Boosting & 0.80 & 0.004 & 9.7 & 0.81 \\ XGBoost & 0.83 & 0.002 & 9.1 & 0.50 \\ Extra Trees & 0.82 & 0.005 & 9.5 & 0.72 \\ CatBoost & 0.84 & 0.003 & 8.8 & 0.55 \\ SVR (RBF Kernel) & 0.75 & 0.009 & 12.3 & 1.60 \\ Stacking Regressor & 0.88 & 0.002 & 7.0 & 0.36 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Model performance across the different train–test splits. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **Best Hyperparameters** & **Test R\({}^{2}\)** & **R\({}^{2}\) Variance** & **Test RMSE** & **RMSE Variance** \\ \hline Linear Regression & \(-\)(no hyperparameters) & 0.50 & 0.010 & 15.0 & 2.25 \\ Ridge Regression & \(\alpha=0.5\) & 0.58 & 0.008 & 13.2 & 1.89 \\ Lasso Regression & \(\alpha=0.1\) & 0.45 & 0.012 & 17.5 & 3.10 \\ Random Forest & \(\begin{array}{c}n\_\text{estimators}=100,\\ max\_\text{depth}=10\end{array}\) & 0.85 & 0.003 & 8.4 & 0.64 \\ Extra Trees & \(\begin{array}{c}n\_\text{estimators}=100,\\ max\_\text{depth}=10\end{array}\) & 0.82 & 0.005 & 9.5 & 0.72 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: The best hyperparameters and test performance for traditional and ensemble models, along with cross-validation variance. The tree-based ensemble models and other advanced regressors dramatically outperformed the linear models, achieving both a better fit and lower variability across splits.