Abstract
Background and objectives
Periprosthetic joint infection (PJI) is a serious complication that can occur after joint arthroplasty, such as hip or knee replacement surgeries. It involves the invasion of the periprosthetic space by pathogens, leading to severe inflammation and often requiring complex medical intervention. PJI is associated with significant morbidity, increased healthcare costs, and a reduced quality of life for patients. This study aims to evaluate the performance of multiple supervised machine learning models in predicting PJI using clinical and demographic data collected from patients who underwent joint arthroplasty.
Methods
Eight supervised machine learning models—Logistic Regression, Random Forest, XGBoost, Artificial Neural Network (ANN), k-Nearest Neighbors (KNN), AdaBoost, Gaussian Naive Bayes (GNB), and Stochastic Gradient Descent (SGD)—were trained and tested on a dataset of 27,854 patients. Models were evaluated using accuracy, precision, recall, specificity, F1 score, and area under the ROC curve (AUC).
Results
Random Forest and XGBoost showed the best overall performance, with high accuracy and balanced metrics across all evaluation criteria. KNN also performed strongly, particularly in minimizing misclassifications. GNB and SGD yielded weaker results, with higher error rates.
Conclusion
Random Forest, XGBoost, and KNN are the most promising models for clinical implementation in PJI prediction. Their robust performance may support earlier diagnosis and improved patient outcomes in orthopedic care.
Translational potential statement
This study demonstrates that machine learning models—particularly Random Forest and XGBoost—can accurately predict periprosthetic joint infection (PJI) using structured electronic health record data. By integrating these models into preoperative assessment workflows, clinicians may be able to identify high-risk patients earlier, personalize prophylactic strategies, and reduce infection-related morbidity. The implementation of these predictive tools has the potential to enhance clinical decision-making, improve surgical outcomes, and optimize the use of healthcare resources in orthopedic practice.
Keywords: Artificial intelligence, Classification metrics, Machine learning, Orthopaedics, Periprosthetic joint infection, Predictive modelling
Graphical abstract
1. Introduction
Periprosthetic joint infection (PJI) is recognized as one of the most serious complications following joint arthroplasty, such as hip and knee replacements. PJI is characterized by the invasion of the periprosthetic space by pathogenic microorganisms, leading to severe inflammation and often necessitating complex interventions, including revision surgery [1,2]. The consequences of PJI are profound, not only causing significant patient morbidity and mortality but also prolonged hospital stays contributing to substantial healthcare costs. Moreover, PJI can severely impact patients' quality of life, leading to pain, impaired mobility, and in most cases requiring complex surgeries with highly demanding technical issues including the removal of the prosthesis [3]. Unfortunately, the precise early diagnostic of PJI is rather difficult, especially due to the non-specific signs and symptoms [4].
Despite advances in surgical techniques, infection control measures, and perioperative care, the incidence of PJI remains a persistent challenge. Studies have reported that the incidence of PJI ranges from 1 % to 2 % following primary total joint arthroplasty, with a notably higher rate observed in revision surgeries [5,6]. This variability underscores the complexity of PJI and the difficulty in its early detection and management. Early identification of PJI is crucial to initiating timely treatment, which can significantly improve patient outcomes. The ‘gold standard’ diagnosis of PJI is still debatable, with some organizations still trying to develop diagnostic scores and criteria in order to rapidly and early detect a PJI [7]. However, the diagnosis of PJI is often complicated by the nonspecific nature of its early symptoms and the limitations of conventional diagnostic methods, such as clinical evaluation, serum biomarkers, and imaging [8].
Traditionally, the diagnosis of PJI relies on a combination of clinical signs, imaging signs, laboratory tests (including elevated non-specific inflammatory markers such as erythrocyte sedimentation rate (ESR), white blood count (WBC), fibrinogen (FIB) and C-reactive protein (CRP), and microbiological cultures, as advised by the Musculoskeletal Infection Society (MSIS) and the Infectious Disease Society of America (IDSA) [9]. However, these methods are not always sufficient to detect PJI accurately, particularly in its early stages. The sensitivity and specificity of these tests can vary, leading to cases of misdiagnosis or delayed diagnosis, which in turn can result in the progression of the infection and worsening of the patient's outcomes [10,11]. Therefore, there is a critical need for more reliable and precise diagnostic tools that can enhance the early detection of PJI.
In recent years, machine learning (ML) has emerged as a transformative tool in the field of healthcare, offering new possibilities for improving diagnostic accuracy and predictive analytics. Although Artificial Intelligence (AI) is not a new tool in healthcare, its use in the field of orthopedics and traumatology has seen a rise in the last decade [12]. ML models can analyze large and complex datasets, identifying patterns and correlations that may not be apparent through traditional statistical methods. This capability makes ML particularly well-suited for applications in medical diagnosis, where it can provide insights into disease prediction, patient outcomes, and treatment efficacy [13,14]. Several studies have demonstrated the potential of ML models in predicting various postoperative complications, including infections, by utilizing a range of clinical data inputs [15,16].
However, the application of ML to the specific task of predicting PJI remains relatively underexplored. The number of performed arthroplasties continues to increase annually, with an important amount of patient and surgery data available due to the electronic medical record system, which provides adequate information for research in this field [17,18]. Given the high stakes associated with PJI, including the potential for severe patient outcomes and increased healthcare costs, there is a compelling need to develop and evaluate ML models that can predict this complication with high accuracy. The ability to predict PJI effectively could lead to more personalized and timely interventions, ultimately improving patient outcomes and reducing the burden on healthcare systems.
This study aims to address this gap by systematically evaluating the performance of various supervised ML models in predicting PJI. Using a large dataset of clinical data collected from patients who underwent joint arthroplasty, the study compares the performance of several models, including Logistic Regression, Random Forest, XGBoost, Artificial Neural Network (ANN), k-Nearest Neighbors (KNN), AdaBoost (AB), Gaussian Naive Bayes (GNB), and Stochastic Gradient Descent (SGD). Each model is assessed based on key performance metrics such as accuracy, precision, recall, specificity, F1 score, and area under the curve (AUC). By identifying the most effective model, this research seeks to enhance the early detection of PJI, thereby improving clinical decision-making and patient care in orthopedic surgery.
2. Related work
Although research on predicting periprosthetic joint infection using ML is still in its early stages, several significant studies have demonstrated the potential of these methods in accurately diagnosing PJI and other complex medical conditions. This section explores key studies in this field, highlighting the various ML techniques utilized and their corresponding outcomes. By reviewing these works, we aim to gain insights into the current state of PJI prediction research, which in turn informs the methodology and goals of our study.
Kuo F.-C. et al., in their study, employ ML algorithms such as Random Forest, eXtreme Gradient Boosting (XGB), Logistic Regression, Naïve Bayesian, and a meta-learner based on Support Vector Machine (SVM) to predict periprosthetic joint infection (PJI). Data were collected from 323 patients undergoing revision total joint arthroplasty, focusing on various biomedical features and comorbidities. The models identified key predictors, with the best-performing model, the meta-learner, achieving an accuracy of 96.4 %, a precision of 96.0 %, a recall of 98.1 %, an F1 Score of 97.0 %, and an AUC of 0.988 [19].
Wouthuyzen-Bakker M. et al., in their study, employ ML techniques, including random forest analysis, along with other algorithms such as logistic regression and support vector machines (SVM), to predict the failure of the debridement, antibiotics, and implant retention (DAIR) procedure in patients with acute periprosthetic joint infections (PJI). Data were collected from over 1000 patients who underwent irrigation and debridement of hip or knee prostheses. Among the models, the random forest algorithm identified key predictors of DAIR failure, achieving an accuracy of 74 %, a precision of 0.70, a recall of 0.78, an F1 Score of 0.74, and an area under the curve (AUC) of 0.74 [20].
Chen W. et al., in their study, develop a ML-based model for the "in-time" prediction of periprosthetic joint infection (PJI), employing algorithms such as Elastic Net, Linear Support Vector Machine (LSVM), Kernel Support Vector Machine (KSVM), Extra Trees (ET), Light Gradient Boosting Machine (LGBM), Multilayer Perceptron (MLP), and a meta-learner using Ensemble Learning of Weighted Voting (ELWV). Data were collected from 254 patients, focusing on widely accessible clinical indicators. The models identified key predictors, with the best-performing model, the LGBM, achieving an accuracy of 95.0 %, a precision of 97.5 %, a recall of 89.8 %, an F1 Score of 93.3 %, and an AUC of 0.968. These findings demonstrate the potential of machine learning to significantly enhance the diagnostic accuracy of PJI in clinical settings [21].
Paranjape P. R. et al., in their study, develop and validate a multivariable machine learning algorithm to predict the probability of periprosthetic joint infection (PJI) from synovial fluid in patients undergoing hip or knee arthroplasty. The study utilized several machine learning techniques, including unsupervised learning methods like K-means clustering and principal component analysis (PCA), as well as a supervised decision tree model for classification. The decision tree model was trained on data from over 17,000 synovial fluid samples. The algorithm achieved a sensitivity of 99.1 %, a specificity of 97.1 %, a precision (positive predictive value) of 91.9 %, a negative predictive value of 99.9 %, an F1 Score of 95.4 %, and an AUC of 0.993 in predicting PJI [22].
Fu S. et al., in their study, develop a natural language processing (NLP) algorithm to automate the detection of periprosthetic joint infection (PJI) by analyzing electronic health records (EHRs) from patients who underwent total joint arthroplasty (TJA). The study used data from 48,962 TJA procedures and developed the NLP algorithm based on Musculoskeletal Infection Society (MSIS) criteria. The algorithm achieved an accuracy of 99.3 %, a precision of 93.7 %, a recall of 88.7 %, an F1 Score of 91.1 %, and an AUC of 0.991 in predicting PJI [23].
Bülow E. et al., in their study, develop a risk prediction model for periprosthetic joint infection (PJI) within 90 days after total hip arthroplasty (THA) using logistic LASSO regression, combined with bootstrap ranking for variable selection. The study compared this model with other approaches, including univariable prediction models based on the ASA class, Charlson comorbidity index, Elixhauser comorbidity index, and the Rx Risk V comorbidity index, both with and without adjustments for age, sex, and BMI. The key predictors included factors such as the underlying diagnosis for THA, body mass index (BMI), ASA class, sex, age, and the presence of comorbidities like arrhythmia and CNS disease. The best-performing model, which was the LASSO regression model, achieved an accuracy of 68 %, a precision of 56 %, a recall of 68 %, an F1 Score of 61 %, and an AUC of 0.68 in predicting PJI risk [24].
Our study systematically evaluated various machine learning models to predict the risk of PJI following TJA. By utilizing a range of models, including Logistic Regression, Random Forest, XGBoost, Artificial Neural Networks, k-Nearest Neighbors, AdaBoost, Gaussian Naive Bayes, and Stochastic Gradient Descent, we provided comprehensive insights that extend beyond traditional risk assessment methods. Each model's hyperparameters were carefully optimized using cross-validation techniques, ensuring they were fine-tuned for maximum predictive accuracy. This rigorous process enabled a thorough evaluation of the models' capabilities in predicting PJI risk with precision.
In Section III, we explore the strengths and limitations of each machine learning model, offering a detailed analysis of their predictive power and robustness. Section IV presents an exhaustive analysis of simulation results, providing a comprehensive comparative evaluation of algorithm performance. We examine key performance metrics such as accuracy, precision, recall, specificity, F1 Score, and AUC to identify subtle differences in the effectiveness of each model. By synthesizing these findings, we aim to provide orthopedic surgeons and clinicians with a deeper understanding of the predictive capabilities and limitations of machine learning models in assessing the risk of PJI.
In conclusion, Section VI synthesizes the key findings of our research, providing a comprehensive overview of the implications for clinical practice. Our aim is to empower healthcare providers with the insights and tools needed to enhance patient outcomes in PJI management, facilitating early detection and precise intervention through the application of advanced machine learning techniques.
3. Proposed methodology
Our study aimed to develop distinct predictive models to assess the risk of periprosthetic joint infection (PJI) using eight machine learning techniques: Logistic Regression (LR), Random Forest (RF), XGBoost (XGB), Artificial Neural Network (ANN), k-Nearest Neighbors (k-NN), AdaBoost (AB), Gaussian Naive Bayes (GNB), and Stochastic Gradient Descent (SGD). These models will be trained and validated using clinical data from patients who have undergone total joint arthroplasty. The performance of each model will be evaluated and compared by analyzing key metrics, including Accuracy, Precision, Recall, Specificity, F1 Score, and Area Under the Curve (AUC).
3.1. Data collection
The data for this study were collected from “Foisor” Clinical Hospital of Orthopaedics, Traumatology and Osteoarticular TB, Bucharest, Romania, comprising 27,854 records with 41 columns that included patient demographics, clinical data, relevant personal medical history, imagistic data, laboratory findings, type of surgery and outcomes related to periprosthetic joint infection. Data were collected retrospectively from the electronic medical record system of the hospital and included consecutive patients undergoing hip and knee total joint replacements between January 2014 and May 2024. Patient identification and recruitment were performed after study approval by the Ethics Committee of “Foisor” Clinical Hospital of Orthopaedics, Traumatology and Osteoarticular TB, Bucharest, Romania (7846/11.07.2024).
On the day of admission, for each patient blood tests were drawn, radiographic imaging was performed and a thorough clinical examination by an orthopedic resident or specialist was completed. Each labeled blood vacutainers are split, and analyzed on different machines. For the complete blood count (CBC), blood samples are drawn on vacutainers containing K3 EDTA and analyzed on Siemens ADVIA® 2120i. The Erythrocyte Sedimentation Rate (ESR) is drawn on vacutainers with sodium citrate 0.4 ml. and measured manually using the Westergren technique. Biochemistry is drawn on vacutainers without any additives, and after spinning on Hettich ROTINA 35®, it is then analyzed with the help of a Siemens Dimension® machine, which was also used for C-Reactive Protein assessment. The blood samples for coagulation tests as well as fibrinogen were drawn on vacutainers containing sodium citrate 2.7 ml, and after spinning on Hettich ROTINA 35®, were analyzed with the help of the Siemens Sysmex® CA 600 analyzer.
All patients are routinely submitted to radiographs of the affected area, as follows: for a total hip arthroplasty, anteroposterior and lateral views of both hips were performed, whereas for a total knee arthroplasty, a full-length anteroposterior view was performed, along with a lateral view of both knees and an axial view of the patella. All radiographs were performed in our Department of Radiology and Medical Imaging, on a DigitalDiagnost R3.1 machine (Philips Medical Systems Nederland B.V., Amsterdam, The Netherlands).
Upon loading the dataset, a preliminary assessment was conducted to evaluate its structure, the number of entries, and the presence of missing values. This initial exploration provided a foundational understanding that guided subsequent data-cleaning strategies. To streamline the dataset and enhance the focus on relevant variables, several columns were removed, including 'Insurance Status', which was not pertinent to the clinical analysis, 'Number', an arbitrary identifier not necessary for statistical analysis, 'Doctor', which was not relevant for predicting PJI, and 'Admission Diagnosis Text' and 'Discharge Diagnosis Text', which were redundant due to the availability of coded diagnosis data. These adjustments reduced complexity and improved the dataset's suitability for analysis.
A detailed summary of the final dataset structure, including variable names and data types, is presented in Table 1.
Table 1.
Overview of all input features available in the raw dataset before preprocessing, including their general data types and value formats.
| Feature | Values |
|---|---|
| admission_date | Categorical (Date/Time) |
| admission_diagnosis_code | Categorical (Code) |
| discharge_diagnosis_code | Categorical (Code) |
| admission_age | Numerical (Integer) |
| bmi | Numerical (Float) |
| weight | Numerical (Float) |
| height | Numerical (Float) |
| diabetic | Categorical (Yes/No) |
| residence | Categorical (Urban/Rural) |
| pensioner | Categorical (Yes/No) |
| length_of_stay | Numerical (Integer) |
| albumin | Numerical (Float) |
| fibrinogen | Numerical (Float) |
| glycated_hemoglobin | Numerical (Float) |
| c_reactive_protein | Numerical (Float) |
| total_protein | Numerical (Float) |
| urine_culture | Categorical (Text) |
| esr | Numerical (Float) |
| wbc | Numerical (Float) |
| xray_history | Categorical (Text) |
| ct_history | Categorical (Text) |
| mri_history | Categorical (Text) |
| fracture_history | Categorical (Yes/No) |
| implant_history | Categorical (Yes/No) |
| puncture_history | Categorical (Yes/No) |
| surgery_history | Categorical (Yes/No) |
| anticoagulant_history | Categorical (Yes/No) |
| cardiovascular_history | Categorical (Yes/No) |
| antibiotic_history | Categorical (Yes/No) |
| antibiotic_recommendations_history | Categorical (Yes/No) |
| transfusion_history | Categorical (Yes/No) |
| other_pathologies_history | Categorical (Yes/No) |
| suture_history | Categorical (Yes/No) |
| exercise_history | Numerical (Integer) |
| surgery_number | Categorical (Yes/No) |
| septic | Target - Categorical (Yes/No) |
Patients identified as septic underwent a diagnostic protocol in order to demonstrate the presence of PJI, as exemplified in Fig. 1.
Fig. 1.
Schematic representation of the diagnostic algorithm of periprosthetic joint infection (PJI); WBC = white blood cells, ESR = erythrocytes sedimentation rate; CRP = C reactive protein; FIB = fibrinogen; PMN = polymorphonuclear leukocytes.
3.2. Pre-processing
Data preprocessing entails preparing raw data for subsequent analysis and modeling. The first step, data cleaning, focuses on identifying and addressing missing values, outliers, and inconsistencies within the dataset. Furthermore, categorical variables were converted into numerical formats, as most machine learning algorithms require numerical input.
A detailed analysis identified several columns with a high proportion of missing values that could compromise data integrity. As a result, columns such as 'albumin', 'glycated_hemoglobin', 'total_protein', and 'urine_culture' were excluded due to insufficient data availability, which would hinder their utility in reliable statistical modeling. For columns with minor missing data, imputation techniques were applied. The most frequent value (mode) was used to fill missing entries in categorical fields such as 'admission_diagnosis_code', while columns related to medical history, like 'ct_history' and 'mri_history,' were filled with standard text indicators such as 'No exam' or 'No history' to maintain consistency and acknowledge the absence of specific information.
Identifying and managing outliers was an important step in ensuring the dataset's accuracy. Specifically, outliers in the BMI variable were carefully examined for clinical plausibility. Values below 10 or above 100 were considered implausible and likely the result of data entry errors. These values were temporarily marked as missing (NaN) to avoid introducing bias, without removing any patient records. Subsequently, they were imputed using the overall mean BMI, which was appropriate given the approximately normal distribution observed in the data. This approach preserved the dataset's completeness while minimizing the influence of erroneous values. To facilitate further analysis, particularly in statistical modeling and machine learning, categorical variables were converted into numerical formats. For example, variables like 'diabetic' were converted to binary values (0 for 'No' and 1 for 'Yes'), while other categorical data such as 'residence' and 'pensioner' were numerically encoded to reflect their inherent categories.
To address missing data in continuous variables such as 'fibrinogen', 'c_reactive_protein', 'esr', and 'wbc', a more sophisticated imputation approach was applied. Specifically, the missing values were filled based on the 'septic' column. If 'septic' was 1, missing values were replaced with the mean calculated for rows where 'septic' equaled 1. If 'septic' was 0, the mean of rows where 'septic' equaled 0 was used. For cases where no group-specific mean could be calculated, a fallback to the overall column mean was implemented to ensure that no values were left missing. Additionally, columns containing historical entries with both dates and values were cleaned by extracting the most recent value and discarding the associated date to maintain numerical consistency.
Additionally, new features were engineered to enhance the dataset's analytical capabilities. These included binary indicators like 'exercise_present' to denote the occurrence of specific medical events or treatments and count features like 'surgery_count' and 'antibiotic_count' to quantify the frequency of certain interventions or conditions. These engineered features added depth to the dataset [25], enabling a more nuanced understanding of patient outcomes and treatment effectiveness.
The selection of the 41 input features used in model training was guided by both clinical relevance and data quality. An initial set of over 80 variables was extracted from the EMR system, including demographic, laboratory, imaging, and surgical data. Variables with excessive missingness or limited clinical interpretability—such as albumin, urine_culture, total_protein, and insurance_status—were excluded. The final feature set was refined through an iterative process in collaboration with orthopedic clinicians, prioritizing variables with known or plausible associations with PJI (e.g., prior surgery, antibiotic use, inflammation markers). In addition, engineered features such as antibiotic_count, exercise_present, and mri_present were added to capture relevant temporal and diagnostic signals. Although no formal feature selection algorithm (e.g., RFE, LASSO) was applied at this stage, the relevance of features was retrospectively validated using SHAP analysis. Further dimensionality reduction is planned in future iterations.
Variables such as albumin, glycated_hemoglobin, total_protein, and urine_culture were excluded due to excessive missingness—typically over 90 %—which would have severely limited their reliability and introduced significant bias if imputed. For categorical variables with minimal missing data (e.g., residence, diabetic), mode imputation was chosen to preserve the underlying distribution. For continuous variables like bmi or weight, mean imputation was applied after verifying the absence of strong skewness or multimodal patterns. Furthermore, for key clinical biomarkers (CRP, ESR, Fibrinogen, WBC), a stratified imputation method was implemented, using group-specific means based on the septic status, to reduce potential distortion. These decisions ensured a balance between data completeness and clinical validity.
Addressing class imbalance was an important step in refining the dataset for predictive modeling. The target variable, 'septic', exhibited significant class imbalance, with 27,554 instances of the majority class (septic = 0) and only 302 instances of the minority class (septic = 1). To correct this, the SMOTEENN technique was applied. SMOTE (Synthetic Minority Over-sampling Technique) was used to generate synthetic samples for the minority class, balancing the class distribution. ENN (Edited Nearest Neighbors) was then employed to remove samples incorrectly classified by their nearest neighbors, further refining the dataset and reducing noise. As a result, the dataset was balanced with 26,988 instances of the minority class (septic = 1) and 25,765 instances of the majority class (septic = 0), totaling 52,753 rows and 45 columns. Given the initial strong imbalance between septic and non-septic cases, SMOTE-ENN was applied to obtain a balanced dataset suitable for model training and evaluation. Consequently, standard classification metrics—such as precision, recall, specificity, F1-score, and ROC-AUC—were preferred over AUPRC, which is primarily recommended for evaluating models on imbalanced datasets.
A visualization of the relationships between key features was conducted using a correlation heatmap, Fig. 2, providing an intuitive and visually engaging method to display the interactions between variables in the dataset. The heatmap showcases the correlation matrix, highlighting significant relationships such as the strong positive correlation between discharge_diagnosis_code and septic, and notable interactions between features like length_of_stay and surgery_number. These correlations underscore the importance of specific clinical factors in predicting septic outcomes. By focusing on these influential attributes, the analysis enhances our understanding of the critical variables that contribute to septic conditions, enabling more accurate predictive modeling and the development of targeted interventions to improve patient outcomes.
Fig. 2.
Pearson correlation heatmap of relevant numerical and binary variables prior to model training. The plot shows pairwise Pearson correlation coefficients, with red indicating strong positive correlations and blue indicating strong negative correlations. Variables include demographic, laboratory, and engineered clinical features.
After completing all preprocessing steps and exploratory data analysis, the dataset was strategically divided into training and testing subsets. This split was executed using an 70:30 ratio, which is a widely adopted standard in machine learning. The rationale behind this choice is to allocate 70 % of the data for training, allowing the model to learn patterns and relationships, while reserving the remaining 30 % for testing to evaluate the model's performance on unseen data. This approach helps to ensure that the model generalizes well to new data, minimizing the risks of overfitting and underfitting, which are common challenges in predictive modeling.
3.3. Methods
The primary goal of our study is to accurately predict PJI by modeling the relationship between various clinical and demographic input variables and the target outcome. To achieve this, we implemented eight different supervised machine learning models. The effectiveness of these models is influenced by several critical factors, including data quality, the selection of relevant features, meticulous hyperparameter tuning, and managing the balance between overfitting and underfitting. Furthermore, the interpretability of these models is essential for understanding and trusting the predictions they generate. Each of these elements plays a significant role in determining the overall accuracy, reliability, and practical utility of the predictive models used in our analysis.
GridSearchCV was utilized to fine-tune the hyperparameters of various machine learning models through cross-validation, a method that divides the training data into multiple subsets. This approach ensures that each model is both trained and validated on different portions of the data, minimizing the risk of the model becoming overly dependent on any single subset. By systematically evaluating each model across all possible hyperparameter combinations, GridSearchCV identified the optimal settings that maximized validation accuracy. The models were then retrained on the complete training dataset using these optimal parameters and subsequently tested on a separate test set to verify their ability to generalize to new, unseen data [26].
Logistic Regression (LR) was optimized using GridSearchCV, which systematically explored various combinations of hyperparameters, including regularization strength (C), penalties (l1 and l2), solvers, and maximum iterations (max_iter). By performing cross-validation on the training data, the best parameters were identified as C = 50, penalty = l1, solver = 'liblinear', and max_iter = 200. These optimal settings were used to train the final model, which, when tested, showed improved accuracy and predictive power, validating the effectiveness of the hyperparameter tuning process.
Random Forest (RF) was optimized by applying GridSearchCV to explore key hyperparameters such as the number of trees (n_estimators), maximum tree depth (max_depth), minimum samples to split a node (min_samples_split), and minimum samples at a leaf (min_samples_leaf). Through cross-validation, the best combination was found to be bootstrap = False, n_estimators = 200, max_depth = 30, min_samples_split = 5, and min_samples_leaf = 1. These parameters were used to train the model on the full dataset, resulting in enhanced predictive performance.
XGBoost (XGB) was fine-tuned using GridSearchCV to identify the optimal hyperparameters by testing combinations of colsample_bytree, gamma, learning_rate, max_depth, n_estimators, and subsample. The best parameters were colsample_bytree = 0.8, gamma = 0, learning_rate = 0.2, max_depth = 10, n_estimators = 200, and subsample = 0.8. These settings were then used to train the final model, leading to significant improvements in accuracy, precision, recall, specificity, F1 score, and ROC AUC on the test set.
Artificial Neural Network (ANN) was designed using the Sequential API from TensorFlow/Keras. The network architecture consisted of three fully connected layers. The input layer was initialized with 128 neurons and a ReLU activation function. Two hidden layers were included with 64 and 32 neurons respectively, each followed by Batch Normalization and Dropout layers to prevent overfitting, with a dropout rate of 0.3. The output layer used a single neuron with a sigmoid activation function for binary classification.
The model was compiled with the Adam optimizer, using a learning rate of 0.001, and the binary cross-entropy loss function. Training was performed with EarlyStopping to monitor the validation loss and stop training if no improvement was observed for 10 epochs, while automatically restoring the best model weights.
The model was trained over a maximum of 500 epochs with a batch size of 64, using scaled input features through the StandardScaler. Evaluation metrics such as Accuracy, Precision, Recall, Specificity, F1 Score, ROC AUC, and Specificity were calculated to assess the performance on the test set.
The k-Nearest Neighbors (k-NN) classifier was systematically fine-tuned using GridSearchCV to identify the optimal hyperparameters for model performance. The tuning process explored different values for n_neighbors (the number of nearest neighbors to consider), the choice of distance metric (which determines how distances between points are calculated), and the weighting function (which controls how neighbors contribute to the classification decision). After testing multiple configurations, the best setup was found to be n_neighbors = 3, utilizing the Manhattan distance metric (p = 1), which calculates the distance as the sum of absolute differences, and applying uniform weighting, where all neighbors contribute equally to the classification.
The AdaBoost (AB) classifier was fine-tuned using GridSearchCV to identify the optimal hyperparameters for the number of weak learners (n_estimators) and the contribution of each learner (learning_rate). After evaluating multiple combinations, the best configuration was found to be n_estimators = 500 and learning_rate = 1.0. This setup allowed the model to achieve excellent predictive performance, balancing high accuracy, precision, recall, and ROC AUC.
Gaussian Naive Bayes (NB) was optimized with GridSearchCV, focusing on var_smoothing to control variance. The best var_smoothing value was 1e-09, which minimized errors and maximized predictive accuracy.
The Stochastic Gradient Descent (SGD) classifier was fine-tuned using GridSearchCV to optimize several hyperparameters, including the loss function, regularization strength, and learning rate strategy. The best configuration was found to be: loss = 'modified_huber', penalty = 'l2' for regularization, alpha = 0.001, learning_rate = 'adaptive', eta0 = 0.01 (initial learning rate), and max_iter = 1000 iterations.
The complete code for data preprocessing and feature engineering is publicly available at: https://github.com/anghelcata/pji-ml-prediction.
3.4. Experimental setup
To conduct the simulations, we utilized eight virtual machines hosted on a server equipped with AMD EPYC 7713 processors, each running at 3.675 GHz. These machines were optimized for high-performance tasks, with 6 cores and 512 GB of RAM per machine, ensuring they could handle large datasets and complex computations without issues. Each virtual machine was also equipped with a 500 GB HDD, providing sufficient storage for simulation data and results. This infrastructure allowed us to efficiently run multiple simulations, perform extensive hyperparameter tuning, and ensure reliable, reproducible results across all experiments.
3.5. System architecture
The methodological framework employed in this study is illustrated in Fig. 3, which details the sequential steps followed to achieve the research objectives. This comprehensive schematic outlines key stages including data collection, preprocessing, feature engineering, model selection, and evaluation. The framework also describes the process of splitting the data into training and validation sets, performing hyperparameter tuning, and analyzing classification results. Each stage is meticulously crafted to ensure that the study's findings are robust, reliable, and valid.
Fig. 3.
System architecture for ML-based PJI prediction, illustrating the pipeline from dataset extraction and feature selection to preprocessing, model training (with hyperparameter tuning), and final evaluation.
In addition to this, Fig. 4 offers a visual representation of how the dataset was utilized during the development of prediction models. These models were built and tested in the Spyder IDE using Python, with the support of powerful libraries such as Pandas for data manipulation, NumPy for numerical computations, TensorFlow for deep learning, and Sci-kit Learn for machine learning tasks. This system architecture not only facilitates a structured approach to the research process but also ensures that each computational task is optimized for accuracy and efficiency, ultimately leading to more reliable predictive models.
Fig. 4.
Schematic representation of the evaluation process applied to all machine learning models, connecting the FOISOR dataset to ROC-AUC analysis and confusion matrix generation.
3.6. Evaluation metrics
To assess prediction models, five widely used evaluation measures were employed. These include Precision, Recall, Specificity, Accuracy (ACC), F1-score, and Area Under the ROC Curve (ROC-AUC). These metrics are frequently used in various applications such as disease diagnosis, fraud detection, and spam filtering to evaluate the performance of binary classifiers.
| (1) |
| (2) |
| (3) |
| (4) |
| (5) |
| (6) |
-
•
where:
-
•
TP is true positive.
-
•
TN is true negative.
-
•
FP is false positive.
-
•
FN is false negative.
-
•
TPR = is true positive rate.
-
•
FPR = is false positive rate.
3.7. Software
Spyder IDE version 5.5.1, paired with Python version 3.11.9, served as the primary platform for developing our programs and optimizing machine learning models. This IDE provided a user-friendly environment that facilitated coding, debugging, and the efficient execution of Python scripts. Utilizing Spyder's robust features, we implemented various machine learning algorithms, performed hyperparameter tuning through Grid Search Cross-Validation (GridSearchCV), and conducted in-depth evaluations to enhance the models' overall performance.
4. Results and analysis
For our analysis, we used a random sampling method to divide the dataset into training and validation sets in a 70/30 ratio. This approach was selected to ensure that both subsets accurately represented the overall data distribution, allowing for a reliable evaluation of the models' performance. To further improve the accuracy of our classification models, we implemented Grid Search Cross-Validation. This technique systematically explored a predefined grid of hyperparameters to identify the best configuration for each model, enhancing their predictive capabilities.
To provide context for the machine learning analysis, we conducted a descriptive statistical evaluation of the study population. Table 2 summarizes the baseline characteristics of the patients, grouped by septic status (septic = 1 vs. septic = 0). Continuous variables are reported as mean ± standard deviation, while categorical variables are presented as the most frequent value and its corresponding percentage. Notable differences were observed between the groups in variables such as length_of_stay, antibiotic_count, and implant_history, suggesting their potential predictive value.
Table 2.
Baseline characteristics of the study population, stratified by septic status. Continuous variables are reported as mean ± standard deviation; categorical variables as the most frequent value (percentage).
| Variable | Septic 0 | Septic 1 | Total |
|---|---|---|---|
| admission_age | 60.30 ± 14.57 | 64.30 ± 9.43 | 62.35 ± 12.38 |
| bmi | 29.14 ± 4.13 | 29.76 ± 3.52 | 29.46 ± 3.84 |
| weight | 81.88 ± 13.25 | 85.03 ± 11.10 | 83.49 ± 12.30 |
| height | 1.67 ± 0.09 | 1.69 ± 0.06 | 1.68 ± 0.08 |
| length_of_stay | 7.62 ± 4.39 | 18.23 ± 11.10 | 13.04 ± 10.03 |
| surgery_count | 2.11 ± 0.99 | 2.57 ± 1.48 | 2.35 ± 1.28 |
| antibiotic_count | 3.21 ± 4.11 | 30.04 ± 25.03 | 16.94 ± 22.55 |
| diabetic = No | 88.5 % | 95.8 % | 92.3 % |
| residence = Urban | 65.7 % | 64.4 % | 50.3 % |
| pensioner = No | 63.5 % | 97.2 % | 80.7 % |
| fracture_history = Yes | 97.4 % | 93.9 | 95.6 % |
| implant_history = No | 99.5 % | 70.6 % | 84.7 % |
| cardiovascular_history = No | 37.0 % | 13.8 % | 25.1 % |
| exercise_present = No | 90.5 % | 96.9 % | 93.7 % |
A descriptive statistical analysis was performed to characterise the study population and support the interpretation of model outcomes. Table 2 presents 14 clinically relevant demographic and medical variables, stratified by septic status (septic = 1 vs. septic = 0). Continuous variables are displayed as mean ± standard deviation, while categorical variables are shown as the most frequent value with its corresponding percentage.
The two groups exhibited notable differences in several features, particularly in length_of_stay, antibiotic_count, and implant_history, all of which were subsequently confirmed as important predictors by the machine learning models.The performance of eight different supervised machine learning models was then evaluated using key metrics such as accuracy, precision, recall, specificity, F1 score, and AUC. These results are summarized in Table 3, offering a detailed comparison of each model's effectiveness in predicting PJI.
Table 3.
Performance metrics for all eight machine learning models evaluated in this study, including accuracy, precision, recall, specificity, F1 score, and AUC-ROC.
| Model | Accuracy | Precision | Recall | Specificity | F1 Score | ROC-AUC |
|---|---|---|---|---|---|---|
| Logistic Regression | 0.9803 | 0.9853 | 0.9761 | 0.9847 | 0.9807 | 0.9804 |
| Random Forest | 0.9975 | 0.9957 | 0.9995 | 0.9955 | 0.9976 | 0.9975 |
| XGBoost | 0.9965 | 0.9941 | 0.9991 | 0.9938 | 0.9966 | 0.9965 |
| Artificial Neural Network | 0.9963 | 0.9951 | 0.9977 | 0.9948 | 0.9964 | 0.9962 |
| k-Nearest Neighbors | 0.9942 | 0.9888 | 1.0000 | 0.9881 | 0.9944 | 0.9940 |
| AdaBoost | 0.9930 | 0.9916 | 0.9947 | 0.9912 | 0.9932 | 0.9929 |
| Gaussian Naive Bayes | 0.9260 | 0.9606 | 0.8923 | 0.9615 | 0.9252 | 0.9269 |
| Stochastic Gradient Descent | 0.9273 | 0.9242 | 0.9348 | 0.9193 | 0.9295 | 0.9271 |
The results indicate that various ML algorithms were trained to predict PJI, a critical medical condition. Among the models, the Random Forest classifier consistently outperformed other methods across all performance metrics. It achieved an accuracy of 0.9975, precision of 0.9957, recall of 0.9995, and an F1 score of 0.9976, with an AUC-ROC of 0.9975 and a specificity of 0.9955. These metrics suggest that Random Forest not only provided highly accurate predictions but also effectively balanced precision and recall while maintaining a high specificity. This makes it the most reliable model for detecting PJI, excelling at both identifying true positive cases and minimizing false positives. The Random Forest model was also evaluated in terms of computational efficiency. It required approximately 33.02 s for training and 0.53 s to generate predictions for the entire test set, resulting in an average per-sample prediction time of 0.000033 s. These results support its suitability for real-time clinical deployment.
The XGBoost model also demonstrated excellent performance, achieving an accuracy of 0.9965, precision of 0.9941, recall of 0.9991, an F1 score of 0.9966, an AUC-ROC of 0.9965, and a specificity of 0.9938. This combination of high precision, recall, and specificity highlights XGBoost's robustness in handling complex medical data related to PJI, making it a strong contender for accurate infection detection.
The Artificial Neural Network (ANN) also performed well, with an accuracy of 0.9963, precision of 0.9951, recall of 0.9977, an F1 score of 0.9964, an AUC-ROC of 0.9962, and a specificity of 0.9948. ANN's ability to model complex non-linear relationships within medical data contributed to its robust overall performance, making it an effective tool for PJI prediction.
The k-Nearest Neighbors (k-NN) model followed closely with an accuracy of 0.9942, precision of 0.9888, recall of 1.0000, an F1 score of 0.9944, an AUC-ROC of 0.9940, and a specificity of 0.9881. The k-NN model's perfect recall indicates that it successfully identified all true positive PJI cases, though its slightly lower specificity reflects a minor trade-off in distinguishing true negatives.
The AdaBoost model offered reliable performance, achieving an accuracy of 0.9930, precision of 0.9916, recall of 0.9947, an F1 score of 0.9932, an AUC-ROC of 0.9929, and a specificity of 0.9912. While AdaBoost's recall was slightly lower compared to the top models, it still demonstrated strong predictive capabilities, maintaining a good balance between precision and recall for detecting PJI.
The Logistic Regression (LR) model performed reasonably well, with an accuracy of 0.9803, precision of 0.9853, recall of 0.9761, an F1 score of 0.9807, an AUC-ROC of 0.9804, and a specificity of 0.9847. While LR did not achieve the same performance level as ensemble models, it provided consistent and reliable predictions, particularly in minimizing false positives, which is crucial in medical diagnostics.
The Gaussian Naive Bayes (GNB) model, while delivering lower performance than the ensemble methods, achieved a respectable balance with an accuracy of 0.9260, precision of 0.9606, recall of 0.8923, an F1 score of 0.9252, an AUC-ROC of 0.9269, and a specificity of 0.9615. Its high precision and specificity suggest its strength in correctly identifying negative cases, though it struggled more with identifying all positive PJI cases (recall).
Finally, the Stochastic Gradient Descent (SGD) model exhibited the lowest performance, with an accuracy of 0.9273, precision of 0.9242, recall of 0.9348, an F1 score of 0.9295, an AUC-ROC of 0.9271, and a specificity of 0.9193. While SGD's overall performance was weaker than other models, its relatively high recall indicates that it effectively identified positive PJI cases, although at the cost of some false positives.
In conclusion, the Random Forest model emerged as the most accurate and balanced predictor for detecting periprosthetic joint infection (PJI), followed closely by XGBoost and Artificial Neural Networks (ANN), both of which demonstrated strong performance across metrics. k-Nearest Neighbors (k-NN) also performed well, particularly excelling in recall while AdaBoost and Logistic Regression offered dependable results with high precision and specificity. Although Gaussian Naive Bayes and Stochastic Gradient Descent (SGD) were outperformed by more advanced models, they still provided valuable insights, especially in contexts where high precision or recall is essential for medical diagnosis.
Fig. 5 illustrates the Receiver Operating Characteristic (ROC) curves generated for each of the machine learning models used in our study. The ROC curves clearly demonstrate that the Random Forest, k-Nearest Neighbors (kNN), and XGBoost models outperform the others, as indicated by their higher AUC-ROC scores. These elevated AUC values suggest that these models possess strong discriminatory capabilities, effectively distinguishing between the classes and making accurate classifications. This superior performance highlights the reliability and robustness of these models in the context of predicting PJI.
Fig. 5.
Receiver Operating Characteristic (ROC) curves for all eight machine learning models evaluated for PJI prediction. Curves are based on test set performance, with area under the curve (AUC) used to assess discriminatory ability.
In Fig. 6, confusion matrices for the seven machine learning algorithms were generated.
Fig. 6.
Confusion matrices for seven machine learning models used in PJI prediction, showing true positive (TP), true negative (TN), false positive (FP), and false negative (FN) counts based on the test set.
Beginning with the models that exhibit weaker performance, Stochastic Gradient Descent (SGD) and Gaussian Naive Bayes show higher levels of misclassification. These models have an increased number of false positives (FP) and false negatives (FN), indicating they are more prone to errors when distinguishing between positive and negative cases. Despite having relatively balanced true positive (TP) and true negative (TN) rates, their elevated misclassification rates suggest challenges in accurately predicting periprosthetic joint infection (PJI). In particular, Gaussian Naive Bayes struggles with high FN values (874) and 297 FP cases, which indicates difficulty in correctly identifying true positives and negatives.
Logistic Regression and Artificial Neural Networks (ANN) offer moderate classification accuracy. While these models maintain balanced TP and TN rates, they also have slightly higher FP and FN counts. Logistic Regression has 118 FP and 194 FN, while ANN reports 40 FP and 19 FN. This suggests that while these models can reasonably classify instances correctly, they still exhibit a tendency to misclassify some cases, thus requiring further refinement to reduce errors in clinical predictions.
The k-Nearest Neighbors (kNN) model, on the other hand, demonstrates significant improvement, with a noticeable reduction in FP and FN values. kNN recorded 92 FP and 0 FN, underlining its robustness in minimizing classification errors. kNN's strength lies in its ability to accurately classify data points by considering the similarity between instances, resulting in fewer misclassifications, particularly in terms of false negatives, where it achieved a perfect score.
Among all the models, Random Forest and XGBoost stand out as the most effective. Both models consistently achieved low FP and FN counts, with Random Forest having 35 FP and 4 FN, while XGBoost reported 48 FP and only 7 FN. Their well-balanced TP and TN rates contribute to their high classification accuracy. These models are particularly well-suited for PJI prediction, offering reliability and precision in distinguishing between infected and non-infected cases. Random Forest and XGBoost are the top performers, providing balanced and accurate classification, essential for minimizing errors in a medical context.
In summary, the comparative analysis of the eight machine learning models highlights their varying effectiveness in predicting PJI. Random Forest and XGBoost models consistently outperformed others, demonstrating high accuracy, precision, and recall, with a balanced performance across all metrics. The k-Nearest Neighbors (kNN) model also showed strong results, particularly in reducing misclassification errors, making it a reliable option for minimizing prediction errors. Conversely, Gaussian Naive Bayes and Stochastic Gradient Descent (SGD) models were less effective, with higher rates of misclassification, suggesting their limited suitability for this specific medical application. These findings underscore the importance of selecting the most appropriate model based on the specific needs of the prediction task, with Random Forest, XGBoost, and kNN emerging as the most suitable models for accurately predicting PJI.
Compared to existing studies on PJI prediction, our results show a clear performance advantage. For example, while previous works typically report AUC-ROC values between 0.88 and 0.98 and F1-scores up to 0.97, our Random Forest model achieved an AUC of 0.9975 and an F1-score of 0.9976. These values represent, to our knowledge, the highest published to date. In addition to predictive performance, our model achieves a prediction time of 0.000033 s per patient, suitable for real-time clinical deployment. We attribute these improvements to the combination of large-scale, high-quality data, features engineered from semi-structured EMR data, and systematic model optimization.
5. Discussion
In this study, we evaluated the performance of eight supervised machine learning models for predicting periprosthetic joint infection (PJI), including Logistic Regression (LR), Random Forest (RF), XGBoost (XGB), Artificial Neural Network (ANN), k-Nearest Neighbors (KNN), AdaBoost, Gaussian Naive Bayes (GNB), and Stochastic Gradient Descent (SGD). The models were assessed using key performance metrics: accuracy, precision, recall, specificity, F1 score, and area under the curve (AUC-ROC).
Although several prior studies have used machine learning to predict PJI, our study introduces multiple innovations that extend beyond existing literature. First, we utilize a dataset of 27,854 patients, which provides substantial statistical power and model stability. While this size is considerable, we acknowledge that some studies may include either smaller or larger populations. Second, we implement a rich feature engineering pipeline that transforms semi-structured EMR data into clinically meaningful variables, including: binary indicators (e.g., exercise_present), historical event counts (e.g., antibiotic_count, surgery_count), modality-specific indicators (e.g., ct_present, mri_present), and logic-based encodings for missing or textual data. These derived features were designed in collaboration with clinicians to preserve medical relevance and enhance model interpretability. Third, we apply SMOTE-ENN to address severe class imbalance prior to model training, ensuring robust and unbiased evaluation. Fourth, we compare eight machine learning models side by side under uniform conditions, with hyperparameter tuning and a diverse set of metrics (accuracy, F1, specificity, AUC). Lastly, the current study is limited to structured EMR data; unstructured inputs such as radiological images, clinical notes, or microbiology reports were not included, representing a limitation of the current analysis.
In clinical practice, the diagnosis of PJI is based on the experience of the clinician, taking into account the patient's risk factors, modified laboratory work, and imaging interpretation. The difficulty in predicting a PJI relies on the various and non-specific signs and symptoms, that can easily be misclassified. Applying machine learning models in the prediction of PJI may help patients weigh the potential risk of infection and the benefits of a total arthroplasty [27]. With the ability to identify relationships between the different values in the database for a large number of records, machine learning models can help identify those values that are modifiable according to their risk of PJI [[28], [29], [30]].
Random Forest (RF) emerged as the most accurate model across all metrics, achieving an exceptional balance of high accuracy (0.9975), precision (0.9957), recall (0.9995), and an almost perfect AUC-ROC of 0.9975. The model demonstrated low misclassification rates, making RF an exceptionally reliable tool for predicting PJI. Its ability to handle numerous input features while providing insights into feature importance further supports its utility in clinical applications. This makes RF particularly valuable in high-stakes medical contexts, such as early infection detection, where both precision and recall are crucial.
XGBoost (XGB) also performed excellently, closely rivaling RF with an accuracy of 0.9965, precision of 0.9941, recall of 0.9991, and an AUC-ROC of 0.9965. Its robustness and efficiency in handling large datasets and complex relationships make it a powerful tool for predictive analytics in medical contexts. However, the computational demands of XGBoost may need to be considered, especially in resource-limited clinical environments. Nonetheless, XGBoost's ability to deliver high precision and recall makes it a standout model for reliable PJI prediction.
The k-Nearest Neighbors (kNN) model demonstrated solid performance, particularly in minimizing false negatives (FN), with an accuracy of 0.9942, precision of 0.9888, recall of 1.0000, and an AUC-ROC of 0.9940. The model's perfect recall suggests that it was highly sensitive to positive PJI cases, making it a potentially useful tool in clinical decision-making, where missing an infection could lead to severe outcomes. kNN's strength lies in its ability to consider proximity between data points, thus minimizing misclassification.
AdaBoost also provided reliable performance, with an accuracy of 0.9930, precision of 0.9916, recall of 0.9947, and an AUC-ROC of 0.9929. Although its recall was slightly lower compared to RF and XGB, AdaBoost still demonstrated strong overall predictive power. This model's high precision suggests its suitability for contexts where minimizing false positives is essential, though the trade-off in recall may be a consideration.
Logistic Regression (LR), while slightly less accurate than the ensemble methods, maintained a solid balance between accuracy (0.9803), precision (0.9853), and recall (0.9761), with an AUC-ROC of 0.9804. LR's simplicity and interpretability make it a valuable model in clinical contexts where explainability is important. Despite its lower overall accuracy, the transparency of LR models ensures that clinicians can easily understand the factors driving predictions, making it a trusted option when model interpretability is critical.
The Artificial Neural Network (ANN) demonstrated strong performance, with an accuracy of 0.9963, precision of 0.9951, recall of 0.9977, and an AUC-ROC of 0.9962. Despite slightly higher error rates compared to RF and XGB, ANN showed its strength in capturing complex, non-linear relationships within the data. Further tuning of the network's architecture could potentially enhance its performance even more, making it suitable for applications where capturing intricate patterns in clinical data is necessary.
Gaussian Naive Bayes (GNB), while outperformed by more sophisticated models, still provided valuable insights with an accuracy of 0.9260, precision of 0.9606, recall of 0.8923, and an AUC-ROC of 0.9269. GNB's simplicity and efficiency make it useful for quick predictions, although its higher rates of false positives and false negatives suggest that it may not be as reliable for high-stakes clinical decisions where predictive accuracy is paramount.
Finally, Stochastic Gradient Descent (SGD), although less effective overall, demonstrated an accuracy of 0.9273, precision of 0.9242, recall of 0.9348, and an AUC-ROC of 0.9271. Despite its lower overall performance, SGD showed a strong recall, making it useful in scenarios where sensitivity to detecting PJI is a priority. However, the higher rates of false positives and misclassifications suggest that SGD may not be as reliable as other models for clinical applications.
The potential use of machine learning models in predicting PJI can help identify the potential risk factors prior to the surgery and adjust those factors that can be modifiable. Moreover, with the growing amount of medical information that can be gathered through electronic medical record systems, different predictors of PJI can be analyzed and validated with the help of artificial intelligence [27].
In summary, Random Forest emerged as the most robust model for PJI prediction, with XGBoost and k-Nearest Neighbors (kNN) also showing significant potential. AdaBoost and Logistic Regression provided reliable and interpretable results, while ANN and GNB demonstrated the importance of balancing model complexity with interpretability. SGD, although less accurate, highlighted the significance of considering recall in sensitive detection tasks. The overall findings emphasize that Random Forest, XGBoost, and kNN are the most suitable models for accurate PJI prediction in clinical settings.
Table 4 provides an overview of the research studies, detailing the proposed models and their reported performance metrics.
Table 4.
Summary of recent studies on machine learning-based prediction of periprosthetic joint infection (PJI), including dataset characteristics, algorithms used, and reported performance metrics.
| Authors (year) | Dataset collection (samples) | Applied Models | Performance (Proposed model) |
|---|---|---|---|
| Bülow E. et al. (2022) | 88,830 Swedish patients, 18,854 Danish patients | Logistic LASSO Regression (proposed), Bootstrap Ranking, Logistic Regression, Random Forest, SVM. | Accuracy: 68.0 % Precision: 56.0 % Recall: 68.0 % F1 Score: 0.61 AUC: 0.68 |
| Wouthuyzen-Bakker M. et al. (2021) | 1000+ patients | Random Forest (proposed), Logistic Regression, Support Vector Machines (SVM), Decision Tree | Accuracy: 74.0 % Precision: 70.0 % Recall: 78.0 % F1 Score: 0.74 AUC: 0.74 |
| Chen W. et al. (2024) | 254 patients | LGBM (proposed), Elastic Net, LSVM, KSVM, Extra Trees, MLP, ELWV, Decision Tree | Accuracy: 95.0 % Precision: 97.5 % Recall: 89.8 % F1 Score: 0.933 AUC: 0.968 |
| Kuo F.-C. et al. (2022) | 323 patients | Meta-learner (SVM based) (proposed), Random Forest, XGBoost, Logistic Regression, Naïve Bayesian | Accuracy: 96.4 % Precision: 96.0 % Recall: 98.1 % F1 Score: 0.97 AUC: 0.988 |
| Fu S. et al. (2021) | 48,962 patients | NLP Algorithm (proposed) | Accuracy: 99.3 % Precision: 93.7 % Recall: 88.7 % F1 Score: 0.911 AUC: 0.991 |
| Paranjape P. R. et al. (2023) | 17,000+ patients | Decision Tree (proposed), K-means Clustering, PCA, Random Forest | Accuracy: 99.1 % Precision: 91.9 % Recall: 99.1 % F1 Score: 0.954 AUC: 0.993 |
| Our (2025) | Foisor Hospital 2013–2024 dataset (27,854 patients) |
Logistic Regression, Random Forest (proposed), XGBoost, Artificial Neural Network, k-Nearest Neighbors, AdaBoost, Gaussian Naive Bayes, Stochastic Gradient Descent | Accuracy: 99.75 % Precision: 99.57 % Recall: 99.95 % Specificity: 99.55 % F1 Score: 0.9976 AUC: 0.9975 |
As shown in Table 4, some recent studies have used large national databases with tens of thousands of cases; however, these are often limited to administrative or billing codes, with minimal clinical granularity. In contrast, our dataset—although smaller in size—is derived from structured EMR data and includes detailed clinical, laboratory, imaging, and surgical history variables. Furthermore, our approach differs in applying advanced feature engineering on text fields, class balancing via SMOTE-ENN, systematic model tuning, and a full set of evaluation metrics (including specificity, F1-score, and computation time). In addition, our use of SHAP values enhances transparency, which is rarely addressed in prior works. These methodological distinctions support both the robustness and practical relevance of our results.
Given that Random Forest outperformed all other models across every evaluation metric, it was selected for further analysis focused on clinical deployment. We assessed its computational efficiency, revealing a training time of 33.02 s and a prediction time of 0.000033 s per patient, demonstrating its suitability for real-time use. Additionally, we conducted a SHAP analysis focused on the septic class to identify the most influential features. The resulting plot, Fig. 7, highlighted antibiotic_count, discharge_diagnosis_code, and cardiovascular_history as the top contributors. These results support both the clinical relevance and interpretability of the model, which are critical for physician acceptance and integration into decision support tools.
Fig. 7.
Mean absolute SHAP values for the top 25 features contributing to the Random Forest model's prediction of septic cases. Higher values indicate greater impact on model output. Features are ordered by importance for class 1 (PJI-positive).
To quantify the contribution of each input feature to model predictions, we applied Shapley Additive Explanations (SHAP) to the Random Forest classifier, which had the best overall performance. We computed the mean absolute SHAP value for each variable to obtain a global interpretability perspective. As shown in Fig. 7, the most influential predictors included antibiotic_count, discharge_diagnosis_code, cardiovascular_history, and exercise_present, all of which have plausible clinical relevance. The use of SHAP enhances both global and local interpretability and allows clinicians to understand not just which features contribute most overall, but also why a specific prediction was made for an individual patient. This improves trust in the model's behavior and supports its use in clinical decision-making.
One of the key limitations of this study is that the dataset originates from a single clinical center. This introduces potential bias due to local clinical practices, population characteristics, and institutional protocols, which may affect the generalizability of the results. Future research should focus on validating these findings using multicenter datasets that reflect broader clinical settings.
Furthermore, due to the complex and often non-specific clinical presentation of PJI, diagnostic uncertainty may lead to patient misclassification in the dataset, which could affect model training and performance.
Additionally, the dataset used in this study consisted solely of structured data extracted from electronic medical records. Unstructured data sources—such as radiology images, surgical notes, and microbiological text reports—were not included. These could contain valuable diagnostic information and should be considered in future multimodal approaches to enhance prediction performance.
From a practical standpoint, the proposed model can be integrated into the preoperative evaluation workflow as part of a clinical decision support system (CDSS). Given its rapid prediction time (0.000033 s per case) and SHAP-based interpretability, the model can provide real-time risk estimates and explain the underlying clinical rationale, thereby supporting surgeon decision-making without interrupting the clinical flow. In future work, the model may be embedded into hospital EMR systems to flag high-risk patients before surgery or during admission, enabling targeted prophylactic strategies. A simplified user interface and prospective validation phase are envisioned for deployment in the “Foisor” Hospital setting.
6. Conclusions
We systematically evaluated eight supervised ML models for predicting periprosthetic joint infection (PJI) following joint arthroplasty. The models included Logistic Regression (LR), Random Forest (RF), XGBoost (XGB), Artificial Neural Network (ANN), k-Nearest Neighbors (KNN), AdaBoost, Gaussian Naive Bayes (GNB), and Stochastic Gradient Descent (SGD). Each model was rigorously assessed using key performance metrics, including accuracy, precision, recall, specificity, F1 score, and area under the curve (AUC-ROC).
Our findings clearly indicate that Random Forest was the most effective model, achieving the highest scores across nearly all performance metrics, including an outstanding AUC-ROC of 0.9975, accuracy of 0.9975, and balanced precision-recall performance. Random Forest's ability to handle complex data structures and large feature sets while maintaining interpretability makes it particularly suitable for clinical applications where both high accuracy and model reliability are essential.
XGBoost (XGB) and k-Nearest Neighbors (KNN) also demonstrated strong predictive capabilities, closely following Random Forest in overall performance. XGBoost, with an AUC-ROC of 0.9965 and accuracy of 0.9965, effectively balanced bias and variance, making it a robust tool for predictive analytics. However, its computational complexity could limit its use in settings with limited resources. KNN stood out with perfect recall, underlining its sensitivity in detecting PJI cases. This model's effectiveness in proximity-based predictions, combined with its AUC-ROC of 0.9940, suggests that KNN could be particularly useful in clinical scenarios where reducing false negatives is vital.
AdaBoost and Logistic Regression (LR) provided reliable and interpretable results. AdaBoost, with high precision (0.9916) and an AUC-ROC of 0.9929, is ideal for scenarios where minimizing false positives is critical. Logistic Regression, though slightly less accurate than the ensemble methods, maintained a solid balance between interpretability and performance, achieving an AUC-ROC of 0.9804 and an accuracy of 0.9803. Its simplicity and transparency make it an attractive option for clinical settings where model explainability is paramount.
The Artificial Neural Network (ANN) demonstrated strong performance with an AUC-ROC of 0.9962 and accuracy of 0.9963, though its slightly higher error rates suggest that further tuning may be needed to enhance its effectiveness. ANN's ability to capture complex nonlinear relationships makes it valuable in medical applications where such interactions are present. Meanwhile, Gaussian Naive Bayes (GNB), although less sophisticated, achieved reasonable accuracy (0.9260) with high precision (0.9606). Its simplicity and efficiency make it a practical choice in situations where computational efficiency and quick, interpretable results are needed, though it is outperformed by more advanced models in this particular application.
Finally, Stochastic Gradient Descent (SGD), while not as strong overall, demonstrated notable recall, making it valuable in contexts where detecting true positive cases of PJI is critical, despite lower overall accuracy (0.9273). Its high sensitivity suggests potential in applications prioritizing recall over precision, though it may be less reliable compared to other models in broader clinical decision-making.
In conclusion, this study highlights the potential of machine learning models in enhancing the prediction of PJI, with Random Forest, XGBoost, and KNN emerging as the top-performing models. These models offer a strong balance between accuracy, precision, recall, and AUC-ROC, making them particularly suited for clinical application in PJI prediction. AdaBoost and Logistic Regression also provided reliable and interpretable results, while ANN and GNB underscored the importance of considering both model complexity and efficiency. SGD, though less accurate, demonstrated its utility in specific high-recall scenarios.
The insights gained from this comparative analysis provide a foundation for further research and potential clinical applications.
Beyond the model performance, these findings carry practical clinical implications. Early identification of patients at high risk for PJI allows for targeted preventive measures, such as optimizing perioperative antibiotic strategies, planning enhanced postoperative monitoring, or adapting surgical approaches. Given its high recall and real-time inference capability, the Random Forest model in particular may be suitable for integration into preoperative decision support systems. By combining interpretability with accuracy, the proposed models can assist clinicians in stratifying risk and making informed, individualized treatment decisions before surgery is performed.
Future work will focus on validating the models in multicenter settings and developing hybrid architectures that combine predictive power with interpretability and operational efficiency.
Author contributions
Conceptualization, S.D., C.A.A., C.A., and C.S.; Methodology, D.E.V., C.A.A., and C.A.; Software, N.D.G. and C.A.; Formal Analysis, D.-G.N., C.A., and C.D.M.D.; Resources, S.D., C.A.A., R.C., C.S.; Data Curation, D.E.V., D.-G.N.; Writing – Original Draft Preparation, S.D., D.E.V., C.A.A., D.-G.N., N.D.G., C.A., C.D.M.D., R.C. and C.S.; Writing – Review & Editing, S.D., D.E.V., C.A., C.S.; Visualization, D.E.V. and C.A.; Supervision, R.C. and C.S. All authors read and approved the final manuscript.
Data availability
The datasets used and/or analyzed during the current study available from the corresponding author on reasonable request.
Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Acknowledgement
Publication of this paper was supported by the University of Medicine and Pharmacy Carol Davila, through the institutional program Publish not Perish.
Contributor Information
Serban Dragosloveanu, Email: serban.dragosloveanu@umfcd.ro.
Diana Elena Vulpe, Email: diana-elena.plescan@drd.umfcd.ro.
Constantin Adrian Andrei, Email: andrei.constantinadrian@gmail.com.
Dana-Georgiana Nedelea, Email: dg_nedelea@yahoo.com.
Nicolae Dragos Garofil, Email: dragos.garofil@umfcd.ro.
Cătălin Anghel, Email: catalin.anghel@ugal.ro.
Christiana Diana Maria Dragosloveanu, Email: christianacelea@gmail.com.
Romica Cergan, Email: r.cergan@gmail.com.
Cristian Scheau, Email: cristian.scheau@umfcd.ro.
References
- 1.Zimmerli W., Trampuz A., Ochsner P.E. Prosthetic-joint infections. N Engl J Med. 2004;351(16):1645–1654. doi: 10.1056/NEJMra040181. [DOI] [PubMed] [Google Scholar]
- 2.Aggarwal V.K., Rasouli M.R., Parvizi J. Periprosthetic joint infection: current concept. Indian J Orthop. 2013;47(1):10–17. doi: 10.4103/0019-5413.106884. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3.Tande A.J., Patel R. Prosthetic joint infection. Clin Microbiol Rev. 2014;27(2):302–345. doi: 10.1128/CMR.00111-13. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4.Hantouly A.T., Alzobi O., Toubasi A.A., Zikria B., Al Dosari M.A.A., Ahmed G. Higher sensitivity and accuracy of synovial next-generation sequencing in comparison to culture in diagnosing periprosthetic joint infection: a systematic review and meta-analysis. Knee Surg Sports Traumatol Arthrosc. 2023;31(9):3672–3683. doi: 10.1007/s00167-022-07196-9. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5.Berbari E.F., Hanssen A.D., Duffy M.C., Steckelberg J.M., Ilstrup D.M., Harmsen W.S., et al. Risk factors for prosthetic joint infection: case-control study. Clin Infect Dis. 1998;27(5):1247–1254. doi: 10.1086/514991. [DOI] [PubMed] [Google Scholar]
- 6.Ghanem E., Parvizi J., Burnett R.S., Sharkey P.F., Keshavarzi N., Aggarwal A., et al. Cell count and differential of aspirated fluid in the diagnosis of infection at the site of total knee arthroplasty. J Bone Joint Surg Am. 2008;90(8):1637–1643. doi: 10.2106/JBJS.G.00470. [DOI] [PubMed] [Google Scholar]
- 7.Chen W., Hu X., Gu C., Zhang Z., Zheng L., Pan B., et al. A machine learning-based model for "In-time" prediction of periprosthetic joint infection. Digit Health. 2024;10 doi: 10.1177/20552076241253531. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8.Rajkomar A., Dean J., Kohane I. Machine learning in medicine. N Engl J Med. 2019;380(14):1347–1358. doi: 10.1056/NEJMra1814259. [DOI] [PubMed] [Google Scholar]
- 9.Jiang Q., Xu C., Chai W., Zhou Y.G., Fu J., Chen J.Y. The 2018 new definition of periprosthetic joint infection is valuable for diagnosis of persistent infection at reimplantation in patients without synovial fluid. J Arthroplast. 2021;36(1):279–285. doi: 10.1016/j.arth.2020.07.023. [DOI] [PubMed] [Google Scholar]
- 10.Obermeyer Z., Emanuel E.J. Predicting the future - big data, machine learning, and clinical medicine. N Engl J Med. 2016;375(13):1216–1219. doi: 10.1056/NEJMp1606181. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11.Kourou K., Exarchos T.P., Exarchos K.P., Karamouzis M.V., Fotiadis D.I. Machine learning applications in cancer prognosis and prediction. Comput Struct Biotechnol J. 2015;13:8–17. doi: 10.1016/j.csbj.2014.11.005. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12.Farhadi F., Barnes M.R., Sugito H.R., Sin J.M., Henderson E.R., Levy J.J. Applications of artificial intelligence in orthopaedic surgery. Front Med Technol. 2022;4 doi: 10.3389/fmedt.2022.995526. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 13.Wu S., Roberts K., Datta S., Du J., Ji Z., Si Y., et al. Deep learning in clinical natural language processing: a methodical review. J Am Med Inf Assoc. 2020;27(3):457–470. doi: 10.1093/jamia/ocz200. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 14.Kurtz S.M., Lau E., Watson H., Schmier J.K., Parvizi J. Economic burden of periprosthetic joint infection in the United States. J Arthroplast. 2012;27(8 Suppl) doi: 10.1016/j.arth.2012.02.022. 61-5.e1. [DOI] [PubMed] [Google Scholar]
- 15.Shohat N., Parvizi J. Prevention of periprosthetic joint infection: examining the recent guidelines. J Arthroplast. 2017;32(7):2040–2046. doi: 10.1016/j.arth.2017.02.072. [DOI] [PubMed] [Google Scholar]
- 16.Parvizi J. 2013. International consensus on periprosthetic joint infection: what was discussed and decided? pp. 542–543. [PubMed] [Google Scholar]
- 17.Mickley J.P., Kaji E.S., Khosravi B., Mulford K.L., Taunton M.J., Wyles C.C. Overview of artificial intelligence research within hip and knee arthroplasty. Arthroplast Today. 2024;27 doi: 10.1016/j.artd.2024.101396. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 18.Sharfstein J.M. Using health care data to track and improve public health. JAMA. 2015;313(20):2012–2013. doi: 10.1001/jama.2015.4795. [DOI] [PubMed] [Google Scholar]
- 19.Kuo Feng-Chih, et al. Periprosthetic joint infection prediction via machine learning: comprehensible personalized decision support for diagnosis. J Arthroplast. 2022;37(1):132–141. doi: 10.1016/j.arth.2021.09.005. [DOI] [PubMed] [Google Scholar]
- 20.Wouthuyzen-Bakker M., Shohat N., Parvizi J., Soriano A. Risk scores and machine learning to identify patients with acute periprosthetic joints infections that will likely fail classical irrigation and debridement. Front Med. 2021;8 doi: 10.3389/fmed.2021.550095. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 21.Chen W., Hu X., Gu C., Zhang Z., Zheng L., Pan B., et al. A machine learning-based model for “In-time” prediction of periprosthetic joint infection. Digital Health. 2024;10 doi: 10.1177/20552076241253531. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 22.Paranjape P.R., Thai-Paquette V., Miamidian J.L., Parr J., Kazin E.A., McLaren A., et al. Achieving high accuracy in predicting the probability of periprosthetic joint infection from synovial fluid in patients undergoing hip or knee arthroplasty: the development and validation of a multivariable machine learning algorithm. Cureus. 2023;15(12) doi: 10.7759/cureus.51036. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 23.Fu S., Wyles C.C., Osmon D.R., Carvour M.L., Sagheb E., Ramazanian T., et al. Automated detection of periprosthetic joint infections and data elements using natural language processing. J Arthroplast. 2021;36(2):688–692. doi: 10.1016/j.arth.2020.07.076. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 24.Bülow E., Hahn U., Andersen I.T., Rolfson O., Pedersen A.B., Hailer N.P. Prediction of early periprosthetic joint infection after total hip arthroplasty. Clin Epidemiol. 2022;14:239–253. doi: 10.2147/CLEP.S347968. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 25.Li Y., Li T., Liu H. Recent advances in feature selection and its applications. Knowl Inf Syst. 2017;53(3):551–577. [Google Scholar]
- 26.Ahmad G.N., Fatima H., Ullah S., Saidi A.S. Imdadullah. Efficient medical diagnosis of human heart diseases using machine learning techniques with and without GridSearchCV. IEEE Access. 2022;10:80151–80173. [Google Scholar]
- 27.Yeo I., Klemt C., Robinson M.G., Esposito J.G., Uzosike A.C., Kwon Y.M. The use of artificial neural networks for the prediction of surgical site infection following TKA. J Knee Surg. 2023;36(6):637–643. doi: 10.1055/s-0041-1741396. [DOI] [PubMed] [Google Scholar]
- 28.Chong Y.Y., Chan P.K., Chan V.W.K., Cheung A., Luk M.H., Cheung M.H., et al. Application of machine learning in the prevention of periprosthetic joint infection following total knee arthroplasty: a systematic review. Arthroplasty. 2023;5(1):38. doi: 10.1186/s42836-023-00195-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 29.Iacobescu P., Marina V., Anghel C., Anghele A.-D. Evaluating binary classifiers for cardiovascular disease prediction: enhancing early diagnostic capabilities. J Cardiovasc Dev Dis. 2024;11(12):396. doi: 10.3390/jcdd11120396. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 30.Anghele A.-D., Marina V., Dragomir L., Moscu C.A., Anghele M., Anghel C. Predicting deep venous thrombosis using artificial intelligence: a clinical data approach. Bioengineering. 2024;11(11):1067. doi: 10.3390/bioengineering11111067. [DOI] [PMC free article] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Availability Statement
The datasets used and/or analyzed during the current study available from the corresponding author on reasonable request.








