Translate this page into:
Machine Learning–Based prediction of complications and residual pain after total knee arthroplasty
⁎Corresponding author: Dirk Müller. dirkmatthias.mueller@mri.tum.de
-
Received: ,
Accepted: ,
This article was originally published by Reed Elsevier India Pvt. Ltd. and was migrated to Scientific Scholar after the change of Publisher.
Abstract
Abstract
Accurate risk adjustment is critical for outcome prediction and quality improvement in total knee arthroplasty (TKA). While machine learning (ML) offers promising capabilities, most models rely solely on patient demographics and comorbidities. The American Association of Hip and Knee Surgeons (AAHKS) has proposed a set of nine risk factors to enhance current models. This study aimed to evaluate these factors using a machine learning model based on eXtreme Gradient Boosting (XGBoost).
We retrospectively analyzed 783 patients who underwent primary TKA at a single academic center between January 2020 and December 2022. Preoperative clinical data and AAHKS-defined risk factors were used to train and evaluate an XGBoost model. The primary outcome measures were: (1) major complications requiring revision, (2) any complication (major or minor), and (3) residual pain at one year (Visual Analog Scale ≥4). Model performance was assessed using area under the curve (AUC), sensitivity, specificity, and accuracy. Feature importance was determined using SHapley Additive exPlanations (SHAP).
The model achieved moderate predictive accuracy for major complications (AUC = 0.68) and any complication (AUC = 0.65), but performed poorly in predicting residual pain (AUC = 0.53). Among AAHKS-defined risk factors, only “smoking” and “previous open reduction and internal fixation (ORIF) of the knee” showed high predictive value. Other proposed variables, such as angular deformity >15°, had limited impact.
An XGBoost-based ML model incorporating AAHKS-defined risk factors showed moderate effectiveness in predicting postoperative complications following TKA. However, the model was unable to reliably predict residual pain. These findings underscore the need for broader inclusion of joint-specific variables and imaging data in future risk adjustment frameworks to enhance personalized care in knee arthroplasty.
Keywords
Total knee arthroplasty
TKA
Risk adjustment
Machine learning
Complication
Feature importance
2 Introduction
Total knee arthroplasty (TKA) is a widely performed and generally successful surgical intervention aimed at relieving pain and restoring function in patients with advanced knee osteoarthritis. Despite its effectiveness, postoperative complications—ranging from wound issues to infections and implant failures—remain a significant concern, with reported rates varying between 1 % and 6 %,1–4 depending on patient characteristics and surgical factors. Identifying patients at elevated risk for such complications is essential to improving outcomes, guiding perioperative management, and informing shared decision-making.
Traditional risk assessment models for TKA have primarily relied on patient-related factors such as age, gender, body mass index (BMI), and comorbidities including diabetes, cardiovascular disease, and smoking status.1,2,4–11 Although these models provide useful population-level insights, they often lack precision for individualized risk prediction.
Recent advances in machine learning (ML) have shown promise in addressing this limitation.12–23 ML algorithms can analyze complex, high-dimensional data to detect non-linear relationships and interactions among variables, offering the potential for more accurate and personalized risk prediction.24 Prior ML models in TKA have demonstrated varying performance in predicting complications, readmissions, and patient-reported outcomes, with reported AUCs ranging from 0.60 to 0.87. Notably, El-Galaly et al. attempted to predict early revision TKA using data from the Danish Knee Arthroplasty Registry and concluded, that is was not possible to develop a clinically useful model based on preoperative register data.16
The American Association of Hip and Knee surgeons (AAHKS) has prosed a list of nine risk factors in TKA to improve risk adjustment models.25 The objective of this study was to evaluate the predictive value of these risk factors in our well-characterized, single-center patient cohort. We hypothesized that a machine learning model based on the eXtreme Gradient Boosting (XGBoost) framework would be capable of predicting postoperative complications using these risk factors.
3 Materials and methods
3.1 Data source
We retrospectively analyzed all primary TKAs performed at our university hospital between January 2020 and December 2022 (n = 934). According to our institutional protocol, all patients underwent standardized clinical evaluations preoperatively, at 6 weeks postoperatively, and at 1 year postoperatively. Informed consent was obtained from all individual participants included in the study. Ethical approval was waived by the local ethics committee of the Technical University of Munich (IRB approval number 714/20 S).
3.2 Data screening, cleaning and preparation
Patients who did not attend the 6-week and 1-year follow-up examination (n = 151) were excluded from the analysis. The final study cohort comprised 783 patients, yielding a follow-up rate of 83.8 %. The CONSORT flow diagram of patient inclusion and follow-up is shown in Fig. 1.

A complete clinical examination, including measures of range of motion was performed before surgery, 6 weeks postoperative and one year postoperative. The radiographic evaluation included a standing long leg radiograph, a lateral radiograph of the knee and a skyline view of the patella. Joint specific measurements of radiographs were manually performed by orthopaedic residents. Patient characteristics are displayed in Table 1.
| Patient characteristics | (n = 783) |
| Gender female/male (%) | 56.1 %/43.9 % |
| Age (years at surgery, median, range) | 71 (39–98) |
| BMI (kg/m2, median, range) | 27.9 (14.9–57.1) |
| ASA = 1 (%) | 9.8 % |
| ASA = 2 (%) | 67.7 % |
| ASA = 3 (%) | 22.4 % |
| ASA = 4 (%) | 0.1 % |
| Hip Knee Angle (°, median, range) | 5.0° varus (24.7° varus - 30.3° valgus) |
3.3 Risk factors
Risk factors for the ML model were generally accepted risk factors in hip and knee arthroplasty and the risk factors proposed by the American Association of Hip and Knee Surgeons (AAHKS) to improve risk adjustment in arthroplasty care4,25 (https://www.aahks.org/practice-resources/risk-stratification/), Table 2.
| General risk factors | Relative (%) |
| Male gender | 43.9 % |
| Age <55 years | 7.4 % |
| Age >80 years | 16.1 % |
| ASA ≥3 | 22.5 % |
| Diabetes (E 10 - E 14) | 13.8 % |
| Risk factors proposed by the AAHKS | |
| BMI >40 (E 66.09) | 5.2 % |
| Smoking (Z 70.0) | 11.2 % |
| Chronic anticoagulant use (Z 79.01) | 28.7 % |
| Chronic narcotic use (F 11.20) | 14.7 % |
| Workmen's compensation case (Z 56.9) | 0.5 % |
| Previous intraarticular infection (B 94.9) | 2.8 % |
| Angular knee deformity >15° (M 21.869) | 12.8 % |
| Previous ORIF knee (M 17.31 right knee, M 17.32 left knee) | 19.3 % |
| Depression/psychiatric disease (F 48.9) | 9.3 % |
3.4 Outcome labels
The primary outcome measures of this study were complications occurring within the first year following total knee arthroplasty and residual pain, defined as a Visual Analogue Scale (VAS) for pain ≥4. Chronic Pain VAS ≥4 is regarded as moderate or severe in patients with chronic musculoskeletal pain.26 Complications were categorized as major or minor. Major complications were defined as those requiring revision surgery or resulting in death related to the index procedure (see Table 3 for classification). Based on these definitions, three binary outcome labels were used for the machine learning models: major complication, any complication (major or minor), and residual pain.
| Absolute (n) | Relative (%) | |
| Major Complication (Revision surgery) | 27 | 3.4 % |
| Periprosthetic Joint Infection | 7 | 0.9 % |
| Wound healing complication | 2 | 0.3 % |
| Hemarthros | 5 | 0.6 % |
| Arthrofibrosis | 6 | 0.8 % |
| Periprosthetic fracture | 2 | 0.3 % |
| Retropatellar arthrosis (with revision surgery) | 2 | 0.3 % |
| Instability | 1 | 0.1 % |
| Death related to surgery | 1 | 0.1 % |
| Aseptic loosening | 1 | 0.1 % |
| Minor Complication (No Revision Surgery) | 32 | 4.1 % |
| Wound healing complication | 14 | 1.8 % |
| Arthrofibrosis | 1 | 0.1 % |
| Erysipel | 5 | 0.6 % |
| Hemarthros | 2 | 0.3 % |
| Partial rupture of the quadriceps tendon | 4 | 0.5 % |
| Deep vein thrombosis | 3 | 0.4 % |
| Periprosthetic fracture | 1 | 0.1 % |
| Renal failure | 1 | 0.1 % |
| Drop foot | 1 | 0.1 % |
3.5 Descriptive statistics
Descriptive statistical analyses were performed using IBM SPSS Statistics for Windows, version 29.0 (IBM Corp., Armonk, NY, USA). The normality of continuous variables was assessed using the Shapiro–Wilk test. Variables with a normal distribution are reported as mean ± standard deviation, while non-normally distributed variables are presented as median with range.
3.6 Machine learning model
We developed a machine learning pipeline using XGBoost to perform binary classification for the three target variables. XGBoost is a gradient boosting algorithm that was selected for its ability to model non-linear relationships in structured data. We used 5-fold stratified cross-validation to obtain reliable performance estimates. The data were divided into 5 equal parts. In each iteration, the model was trained on four parts and tested on the remaining part. This process was repeated five times so that each part served once as the test set. Within each training fold, we applied the Synthetic Minority Oversampling Technique (SMOTE) to address class imbalance. Model hyperparameters such as learning rate, maximum tree depth and minimum child weight were tuned using random search.
Model performance was assessed using metrics like sensitivity, specificity, accuracy, and the area under the receiver operating characteristic curve (AUC). Furthermore, to improve interpretability, we used SHapley Additive exPlanations (SHAP) to quantify feature importance. SHAP values indicate how much each feature contributes to the model's prediction. A positive SHAP value shifts the model's prediction towards 1, whereas a negative value shifts the prediction towards 0.
4 Results
The correlation matrix of all input variables is presented in Fig. 2. A summary of the machine learning model results for the three outcome labels—residual pain, any complication, and major complication—is presented in Table 4.

| Residual pain | Any complication | Major complication | |
| Accuracy | 62 % | 84 % | 87 % |
| Sensitivity | 15 % | 20 % | 19 % |
| Specificity | 90 % | 89 % | 90 % |
| AUC | 53 % | 65 % | 68 % |
The ROC curve for the outcome labels “residual pain”, “any complication” and “major complication” is shown in Fig. 3. While any complication and major complication could be predicted with a AUC of 0.65 and 0.68 respectively, the model failed at predicting at residual pain, Fig. 3.

Fig. 4 displays the SHAP values for the most influential features identified by the machine learning models. The strongest predictors of any complications and major complications were smoking status, ASA classification ≥3, and age >80 years."

5 Discussion
The key finding of this study is that an XGBoost-based machine learning model can predict major complications after TKA with an AUC of 0.68 when combining preoperative patient-specific variables and the risk factors proposed by the AAHKS.
Previous studies evaluating ML models to predict TKA complications have shown variable performance. Harris et al. used a LASSO-based model to predict 30-day complications after TKA and THA, reporting an area under the curve (AUC) of 0.64 for any complication.12 Aram et al., analyzing data from a national joint registry, reported an AUC of 0.705 using a random forest model to predict implant survivorship.27 Mohammadi et al. achieved an AUC of 0.86 for predicting 30-day readmissions using a neural network.14
In a collaborative study between the FORCE-TJR registry and AAHKS, combining clinical variables with CMS administrative data improved risk prediction. Specifically, adding five clinical variables (contralateral arthritis severity, BMI, preoperative SF-36 physical function score, Charlson comorbidity index, and smoking status) increased the AUC from 0.65 (administrative data only) to 0.79 using logistic regression.4
ML models for predicting patient satisfaction and patient-reported outcomes (PROMs) after TKA have reported AUCs ranging from 0.60 to 0.87 13,18,28-31. In particular, Huber et al. used an XGBoost model on NHS data and achieved an AUC of 0.87 for predicting postoperative pain (VAS).29 In contrast, our model performed poorly for predicting residual pain, with limited discriminatory power.
The features with highest importance in our model included “smoking”, “ASA classification ≥3”, “age >80 years” —consistent with established risk factors in the literature.1,4,6,8–10,25,32–35 Among the nine risk factors proposed by the AAHKS, only “smoking” and a history of “previous open reduction and internal fixation (ORIF) of the knee” demonstrated a relevant impact on the prediction of complications in our model. Further studies involving larger patient populations are needed to evaluate the predictive value of the remaining AAHKS-defined risk factors.
Interestingly, an angular knee deformity >15° showed limited predictive value in our model. This suggests that its contribution, when analyzed in isolation, may be minimal. Future research should disaggregate angular deformities by varus and valgus alignment and consider additional joint-specific measures such as patellar height (e.g., patella baja/alta) and osteoarthritis severity (e.g., Kellgren–Lawrence score).
Comparisons with previous studies are complicated by heterogeneous outcome definitions. Many U.S.-based models focus on 30-day readmissions, given the availability of CMS data,4 while others studies use revision rates.16 For ML models predicting patient satisfaction, different studies have employed varying patient-reported outcome measures (PROMs), which limits the comparability of both methodologies and results across studies.36
It is important to note that feature importance in ML models reflects the relative contribution of variables to prediction, not causality. As noted by El-Galaly et al., feature importance primarily reflects how a model calculates predictions and may serve as a tool for hypothesis generation rather than confirmation.16
A key limitation in arthroplasty-related ML research is dataset imbalance. Although complications are rare, they are clinically significant. This class imbalance can lead ML models to overfit the majority class, misleadingly inflating accuracy while underperforming on minority outcomes.17 In our study, the major complication rate was only 3.4 %.
This study has several limitations. First, there is no universally accepted definition of complications in TKA, which may limit the generalizability of our findings. The one-year follow-up period was chosen based on available retrospective data, and 16.2 % of patients were lost to follow-up, introducing potential bias. The relatively small dataset and class imbalance, with a low number of complication events, likely constrained the model's performance and generalizability. Additionally, the risk factors proposed by the AAHKS contain only one joint specific measurement (angular knee deformity >15°). Future research should incorporate more radiographic and surgeon-reported measures into machine learning–based risk adjustment for TKA.
In conclusion, this study demonstrates that complications after TKA can be moderately predicted using an XGBoost model trained on the AAHKS-proposed risk factors. Incorporating a broader range of joint-specific variables may enhance model performance and contribute to more robust, individualized risk adjustment frameworks in future orthopaedic research.
Author contributions
Conceptualization and methodology D.M., I.L. and F.H..; data collection A.A.; data screening, cleaning and preparation D.M.; machine learning models A.G., F.H.; writing—original draft preparation D.M.; writing—review and editing I.L., F.H., H.G. and R. v. E.-R. All authors have read and agreed to the published version of the manuscript.
Availability of data and materials
The datasets used and/or analyzed during the current study are available from the corresponding author upon reasonable request.
Declarations
The work described in the manuscript is original research that has not been published previously, and the manuscript is not under consideration for publication elsewhere, either in whole or in part.
Ethics approval and consent to participate
Ethical approval was waived by the local Ethics Committee of Technical University of Munich (IRB approval number 714/20 S). Informed consent was obtained from all individual participants included in the study.
Consent for publication
All authors agreed to publish the study.
Funding
Open Access funding enabled and organized by Project DEAL.
References
- Thirty-day postoperative complications and mortality following total knee arthroplasty: incidence and risk factors among a national sample of 15,321 patients. J Bone Joint Surg Am. Jan 1 2014;96(1):20-26.
- [Google Scholar]
- Hospital volume and surgical outcomes after elective hip/knee arthroplasty: a risk-adjusted analysis of a large regional database. Arthritis Rheum. Aug 2011;63(8):2531-2539.
- [Google Scholar]
- Prosthetic joint infection risk after TKA in the medicare population. Clin Orthop Relat Res. Jan 2010;468(1):52-56.
- [Google Scholar]
- Using joint registry data from FORCE-TJR to improve the accuracy of risk-adjustment prediction models for thirty-day readmission after total hip replacement and total knee replacement. J Bone Joint Surg Am. Apr 15 2015;97(8):668-671.
- [Google Scholar]
- Accuracy and clinical utility of a peri-operative risk calculator for total knee arthroplasty. J Arthroplast. Mar 2013;28(3):445-448.
- [Google Scholar]
- The impact of advanced age on the outcomes of primary total hip and knee arthroplasty for osteoarthritis: a systematic review. JBJS Rev. Feb 2018;6(2)
- [Google Scholar]
- Can the American college of surgeons risk calculator predict 30-Day complications after knee and hip arthroplasty? J Arthroplast. 2015;30(9):5-10.
- [Google Scholar]
- Risk factors for readmissions after total joint replacement: a meta-analysis. JBJS Rev. Jun 14 2021;9(6)
- [Google Scholar]
- Impact of comorbidity on the short- and medium-term risk of revision in total hip and knee arthroplasty. BMC Muscoskelet Disord. Jul 9 2020;21(1):447.
- [Google Scholar]
- Higher rate of early revision following primary total knee arthroplasty in patients under age 55: a cautionary tale. J Arthroplast. Dec 2019;34(12):2918-2924.
- [Google Scholar]
- Risk prediction tools for hip and knee arthroplasty. J Am Acad Orthop Surg. Jan 2016;24(1):19-27.
- [Google Scholar]
- Can machine learning methods produce accurate and easy-to-use prediction models of 30-day complications and mortality after knee or hip arthroplasty? Clin Orthop Relat Res. Feb 2019;477(2):452-460.
- [Google Scholar]
- Predictors of patient satisfaction following primary total knee arthroplasty: results from a traditional statistical model and a machine learning algorithm. J Arthroplast. Nov 2020;35(11):3123-3130.
- [Google Scholar]
- Predicting unplanned readmissions following a hip or knee arthroplasty: retrospective observational study. JMIR Med Inform. 2020;8(11)
- [Google Scholar]
- A novel, potentially universal machine learning algorithm to predict complications in total knee arthroplasty. Arthroplast Today. Aug 2021;10:135-143.
- [Google Scholar]
- Can machine-learning algorithms predict early revision TKA in the Danish knee arthroplasty registry? Clin Orthop Relat Res. Sep 2020;478(9):2088-2101.
- [Google Scholar]
- Prediction of complications and surgery duration in primary TKA with high accuracy using machine learning with arthroplasty-specific data. Knee Surg Sports Traumatol Arthrosc. Apr 2023;31(4):1323-1333.
- [Google Scholar]
- Can machine learning algorithms predict which patients will achieve minimally clinically important differences from total joint arthroplasty? Clin Orthop Relat Res. Jun 2019;477(6):1267-1279.
- [Google Scholar]
- Transfusion after total knee arthroplasty can be predicted using the machine learning algorithm. Knee Surg Sports Traumatol Arthrosc. Jun 2020;28(6):1757-1764.
- [Google Scholar]
- Development and validation of machine learning algorithms for postoperative opioid prescriptions after TKA. J Orthop. Nov-Dec 2020;22:95-99.
- [Google Scholar]
- Machine learning models accurately predict recurrent infection following revision total knee arthroplasty for periprosthetic joint infection. Knee Surg Sports Traumatol Arthrosc. 2022/08/01 2022;30(8):2582-2590.
- [Google Scholar]
- A web-based machine-learning algorithm predicting postoperative acute kidney injury after total knee arthroplasty. Knee Surg Sports Traumatol Arthrosc. Feb 2022;30(2):545-554.
- [Google Scholar]
- Construction and comparison of predictive models for length of stay after total knee arthroplasty: regression model and machine learning analysis based on 1,826 cases in a single Singapore center. J Knee Surg. Jan 2022;35(1):7-14.
- [Google Scholar]
- Machine learning in knee arthroplasty: specific data are key-a systematic review. Knee Surg Sports Traumatol Arthrosc. Feb 2022;30(2):376-388.
- [Google Scholar]
- Cut-off points for mild, moderate, and severe pain on the visual analogue scale for pain in patients with chronic musculoskeletal pain. Pain. Dec 2014;155(12):2545-2550.
- [Google Scholar]
- Estimating an individual's probability of revision surgery after knee replacement: a comparison of modeling approaches using a national data set. Am J Epidemiol. Oct 1 2018;187(10):2252-2262.
- [Google Scholar]
- Can machine learning methods produce accurate and easy-to-use preoperative prediction models of one-year improvements in pain and functioning after knee arthroplasty? J Arthroplast. Jan 2021;36(1):112-117.e6.
- [Google Scholar]
- Predicting patient-reported outcomes following hip and knee replacement surgery using supervised machine learning. BMC Med Inf Decis Making. Jan 8 2019;19(1):3.
- [Google Scholar]
- Development of machine learning algorithms to predict patient dissatisfaction after primary total knee arthroplasty. J Arthroplast. Nov 2020;35(11):3117-3122.
- [Google Scholar]
- Machine learning methods are comparable to logistic regression techniques in predicting severe walking limitation following total knee arthroplasty. Knee Surg Sports Traumatol Arthrosc. Oct 2020;28(10):3207-3216.
- [Google Scholar]
- What are the influencing factors on hip and knee arthroplasty survival? Prospective cohort study on 63619 arthroplasties. Orthop Traumatol Surg Res. Nov 2019;105(7):1251-1256.
- [Google Scholar]
- Is obesity associated with short-term revision after total knee arthroplasty? An analysis of 121,819 primary procedures from the Dutch arthroplasty register. Knee. Dec 2020;27(6):1899-1906.
- [Google Scholar]
- Aseptic loosening after THA and TKA - do gender, tobacco use and BMI have an impact on implant survival time? J Orthop. May-Jun 2019;16(3):269-272.
- [Google Scholar]
- The effect of chronic anticoagulation on early postoperative outcomes following total knee arthroplasty: a TriNetX database study. Arthroplast Today. Jun 2025;33
- [Google Scholar]
- The impact of machine learning on total joint arthroplasty patient outcomes: a systemic review. J Arthroplast. Oct 2023;38(10):2085-2095.
- [Google Scholar]
