The Journal of Arthroplasty, Volume 34, Issue 10, 2272 - 2277.e1

Development of Machine Learning Algorithms for Prediction of Sustained Postoperative Opioid Prescriptions After Total Hip Arthroplasty

Karhade, Aditya V. et al.


Postoperative recovery after total hip arthroplasty (THA) can lead to the development of prolonged opioid use but there are few tools for predicting this adverse outcome. The purpose of this study is to develop machine learning algorithms for preoperative prediction of prolonged opioid prescriptions after THA.


A retrospective review of electronic health records was conducted at 2 academic medical centers and 3 community hospitals to identify adult patients who underwent THA for osteoarthritis between January 1, 2000 and August 1, 2018. Prolonged postoperative opioid prescriptions were defined as continuous opioid prescriptions after surgery to at least 90 days after surgery. Five machine learning algorithms were developed to predict this outcome and were assessed by discrimination, calibration, and decision curve analysis.


Overall, 5507 patients underwent THA, of which 345 (6.3%) had prolonged postoperative opioid prescriptions. The factors determined for prediction of prolonged postoperative opioid prescriptions were age, duration of opioid exposure, preoperative hemoglobin, and preoperative medications (antidepressants, benzodiazepines, nonsteroidal anti-inflammatory drugs, and beta-2-agonists). The elastic-net penalized logistic regression model achieved the best performance across discrimination ( c-statistic = 0.77), calibration, and decision curve analysis. This model was incorporated into a digital application able to provide both predictions and explanations (available at


If externally validated in independent populations, the algorithms developed in this study could improve preoperative screening and support for THA patients at high risk for prolonged postoperative opioid prescriptions. Early identification and intervention in high-risk cases may mitigate the long-term adverse consequence of opioid dependence.

Level of Evidence


Download article