BACKGROUND: Periprosthetic joint infection leads to significant morbidity and mortality after total knee arthroplasty. Preoperative and perioperative risk prediction and assessment tools are lacking in Asia. This study developed the first machine learning model for individualized prediction of periprosthetic joint infection following primary total knee arthroplasty in this demographic. METHODS: A retrospective analysis was conducted on 3,483 primary total knee arthroplasty (81 with periprosthetic joint infection) from 1998 to 2021 in a Chinese tertiary and quaternary referral academic center. We gathered 60 features, encompassing patient demographics, operation-related variables, laboratory findings, and comorbidities. Six of them were selected after univariate and multivariate analysis. Five machine learning models were trained with stratified 10-fold cross-validation and assessed by discrimination and calibration analysis to determine the optimal predictive model. RESULTS: The balanced random forest model demonstrated the best predictive capability with average metrics of 0.963 for the area under the receiver operating characteristic curve, 0.920 for balanced accuracy, 0.938 for sensitivity, and 0.902 for specificity. The significant risk factors identified were long operative time (OR, 9.07
p = 0.018), male gender (OR, 3.11
p <
0.001), ASA >
2 (OR, 1.68
p = 0.028), history of anemia (OR, 2.17
p = 0.023), and history of septic arthritis (OR, 4.35
p = 0.030). Spinal anesthesia emerged as a protective factor (OR, 0.55
p = 0.022). CONCLUSION: Our study presented the first machine learning model in Asia to predict periprosthetic joint infection following primary total knee arthroplasty. We enhanced the model's usability by providing global and local interpretations. This tool provides preoperative and perioperative risk assessment for periprosthetic joint infection and opens the potential for better individualized optimization before total knee arthroplasty.