Background. Postoperative recovery after routine 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 was to develop machine learning algorithms for preoperative prediction of prolonged post-operative opioid use after THA. Methods. A retrospective review of electronic health records was conducted at two academic medical centers and three community hospitals to identify adult patients who underwent THA for osteoarthritis between January 1. st. , 2000 and August 1. st. , 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