**Background:** Despite fast-track protocols reducing length of stay (LOS) and morbidity after total hip (THA) and knee arthroplasty (TKA), a subset of patients still experiences complications. Traditional logistic regression models have limited clinical utility. Machine-learning (ML) may improve prediction, but few studies include fast-track programs or detailed preoperative medication data. This study compared a boosted decision tree ML model to logistic regression for predicting medical complications (LOS>4 days or 90-day readmission) after fast-track THA/TKA.
**Methods:** This cohort study used the Centre for Fast-track Hip and Knee Replacement database, enrolling consecutive primary THA/TKA patients from seven Danish centers (2014-2017). Preoperative comorbidity and prescribed medications (from the Danish National Database of Reimbursed Prescriptions) were prospectively recorded. LOS and readmissions were obtained from the Danish National Patient Registry and medical records. The primary outcome was 'medical' morbidity (e.g., renal failure, falls, pain, thrombosis, anemia, infection) leading to LOS>4 days or 90-day readmission. Data from 2014-2016 (n=18,013) were used for training; 2017 data (n=3,913) for testing. The ML model used boosted decision trees (LightGBM) with 33 preoperative variables; logistic regression (LR) used the same variables. Two parsimonious models used the top 10 variables from each full model. An age-only model served as baseline. Model performance was evaluated using precision, AUROC, AUPRC, Matthews Correlation Coefficient (MCC), and Brier score. Variable importance was assessed via SHAP values. The classification threshold was set to identify 20% of patients as 'high-risk' (positive prediction fraction 20%).
**Key Results:** In the test set (n=3,913), median age was 70 years (IQR 62-76), 59% female, 58% THA. Median LOS was 2 days (IQR 1-2), 7.6% had 90-day readmissions, and the primary outcome occurred in 182 patients (4.7%). At the 20% risk threshold (782 patients classified as high-risk), the full ML model identified 106 true positives (sensitivity 58.2%, precision 13.6%, AUROC 76.3%, AUPRC 15.5%, MCC 21.1%). The full LR model identified 97 true positives (sensitivity 53.3%, precision 12.4%, AUROC 74.7%, AUPRC 15.6%, MCC 18.4%). The parsimonious ML model (top 10 variables) performed better than the full LR model (sensitivity 54.9%, AUROC 75.9%, AUPRC 17.3%). The age-only model was inferior (sensitivity 47.8%, AUROC 69.7%). The probability that the full LR model was better than the full ML model was 17.2%; for the parsimonious ML model it was 26.4%. SHAP analysis showed age and use of walking aids were the most important variables in both models. Eight of the top ten variables were shared. Age-related variation in medication importance was observed: e.g., vitamin-K antagonists increased risk, while direct oral anticoagulants reduced risk; selective serotonin inhibitors increased risk in elderly but decreased risk in patients <60 years.
**Clinical Implications:** The ML model provided a modest but clinically relevant improvement in identifying high-risk patients (approximately 5% more true positives than LR). At the 20% threshold, it captured about 60% of all medical complications, a manageable population for intensified perioperative care in a socialized healthcare system. The parsimonious ML model (using only 10 variables) performed nearly as well as the full ML model, suggesting potential for clinical implementation without excessive data collection. However, for outcomes including LOS>4 days without documented complications, the parsimonious ML model was slightly worse than full LR, indicating that social/logistical factors may be important. The study highlights the value of detailed preoperative medication data and the potential of SHAP analysis for hypothesis generation (e.g., differential risk of VKA vs. DOACs). Limitations include the observational design, limited number of continuous variables, and exclusion of intraoperative data. Overall, ML algorithms may offer slight but meaningful improvements in preoperative risk stratification for fast-track arthroplasty patients.