Abstract
The optimization of hospital length of stay (LOS) for tuberculosis (TB) patients remains a critical challenge in healthcare management. This study employs advanced machine learning (ML) techniques to analyze the impact of clinical pharmacist intervention on LOS and identify key predictive factors. Methods: We analyzed 467 tuberculosis cases using a sophisticated ML approach with cross-validation. The model incorporated multiple clinical parameters, including pharmacological data and patient characteristics. Statistical significance was assessed using Mann-Whitney U tests and effect size calculations. Causal inference was performed using propensity score matching. Results: The ML model demonstrated modest predictive performance on cross-validation (R² = 0.085, RMSE = 16.93 days). Clinical pharmacist intervention was associated with a significant reduction in LOS (Mann-Whitney U = 22,588, P < 0.001, Cohen’s d = -0.25). The mean LOS for the intervention group was 51.2 ± 17.9 days, compared to 55.3 ± 16.1 days in the control group. Propensity score matching confirmed the causal effect (Average Treatment Effect (ATE) = -3.9 days, 95% CI: -6.2 to -1.6, P = 0.001). Conclusions: Our findings provided strong evidence for the beneficial impact of clinical pharmacist intervention in TB treatment, supported by robust statistical and ML analyses. While the predictive model showed limited performance, the identified predictive factors offer valuable insights for optimizing patient care and resource allocation. SUPPLEMENTARY INFORMATION: The online version contains supplementary material available at 10.1186/s12879-025-11810-9.