Extraprostatic extension (EPE) occurs when prostate cancer grows through the capsule of the prostate into the surrounding tissue. Knowing which side of the prostate has cancer extending beyond its capsule, called side-specific EPE (ssEPE), is critically important for surgical planning before radical prostatectomy.
During prostatectomy, surgeons can perform a nerve-sparing approach on either or both sides of the prostate, preserving the neurovascular bundles responsible for erection and urinary continence. However, nerve-sparing on a side with extraprostatic extension risks leaving cancer cells behind, resulting in positive surgical margins, which increase the likelihood of cancer recurrence. Conversely, unnecessary removal of nerve bundles causes avoidable sexual dysfunction and incontinence.
The central challenge is that EPE cannot be reliably detected before surgery. Standard preoperative imaging has limited sensitivity for microscopic EPE (approximately 57%), and most existing predictive models are based on a restricted set of biopsy variables and do not fully leverage the detailed pathological information available from routine prostate biopsy reports.
Previous predictive models for ssEPE, including the well-validated model by Sayyid et al., use variables such as PSA, prostate volume, digital rectal examination findings, and basic Gleason grade group from biopsy. This study aimed to go further by incorporating the complete clinicopathological profile and using machine learning with a specific focus on explainability, so clinicians can understand and trust the model's recommendations.
This retrospective study used data from 507 patients (900 prostatic lobes) from Credit Valley Hospital, Ontario, Canada (2010 to 2020) as the training cohort, and 99 patients (122 lobes) from Mississauga Hospital (2016 to 2020) as the external testing cohort. Each lobe was assessed independently for ssEPE, since EPE may occur unilaterally.
From 25 candidate variables collected from biopsy reports, Boruta feature selection identified 13 relevant features, with 2 removed due to high collinearity, leaving 11 final model features. These included clinical variables (age, PSA) and detailed biopsy features including worst Gleason grade group, percentage of Gleason pattern 4/5, perineural invasion, percentage of positive cores, maximum percentage core involvement, and site-specific findings and core involvement at the base, mid-gland, and transition zone.
The model used XGBoost, an ensemble tree-based machine learning algorithm that builds decision trees sequentially, with each tree correcting the errors of the previous ones. XGBoost was specifically chosen because it is less prone to overfitting and is optimized for SHAP (SHapley Additive exPlanations), the explainability framework used to interpret predictions.
Performance was evaluated using AUROC and area under the precision-recall curve (AUPRC), which is more informative than AUROC for imbalanced datasets where negative cases significantly outnumber positive ones. Decision curve analysis was used to assess clinical utility by measuring net benefit, specifically how many additional patients per 100 cases could safely receive nerve-sparing surgery compared to treating all patients as having EPE.
SHAP (SHapley Additive exPlanations) is a framework based on game theory that assigns each input feature a contribution score for a particular prediction. The final predicted probability is decomposed into additive contributions from each feature, so clinicians can see exactly how much each variable pushed the prediction higher or lower for a specific patient.
Two SHAP visualization tools were applied. Feature importance rankings show which variables have the greatest average impact on predictions across all patients, providing a global view of the model's learned relationships. Partial dependence plots show how a single feature, such as percentage of Gleason pattern 4/5 or PSA level, affects the predicted probability of ssEPE across its full range of values, revealing non-linear relationships that logistic regression cannot capture.
For individual patients, SHAP generates a waterfall chart showing how each specific variable value, for example this particular patient's PSA of 7.96 or their perineural invasion status, contributes positively or negatively to the final risk estimate. This allows clinicians to understand not just what the model predicted but why, which is essential for building trust in AI-assisted clinical decision-making.
This approach addresses a key limitation of previous machine learning models in urology: the black box problem, where models produce accurate predictions without providing any insight into the rationale. By making each prediction explainable, the model enables clinicians to confirm that its reasoning aligns with clinical intuition and to identify unusual cases where the model's explanation might not be trustworthy.
The ML model achieved an AUROC of 0.81 on both the training cohort (cross-validation) and the external testing cohort. This compared favorably to the logistic regression model built with the same features (AUROC 0.78 training, 0.76 testing) and the established baseline model by Sayyid et al. (AUROC 0.74 on both cohorts). All pairwise differences were statistically significant on the training cohort.
On the AUPRC, the ML model also outperformed both comparators: 0.69 versus 0.64 (LR) and 0.59 (baseline) on training; 0.78 versus 0.75 (LR) and 0.70 (baseline) on testing. AUPRC performance is particularly meaningful in this imbalanced setting where roughly 30% to 42% of lobes have ssEPE, as it specifically evaluates performance among the positive cases that matter most clinically.
The ML model's performance was consistent across subgroups stratified by age, institution, and D'Amico risk classification, demonstrating fairness. Calibration was well-aligned with observed outcomes for predicted probabilities from 0 to 40%, with some overestimation of risk above 40% probability in the external cohort.
Notably, the ML model's performance was comparable to newer models that incorporate MRI findings, such as the Martini model (AUROC 0.68 to 0.78) and the Soeterik model (AUROC 0.77 to 0.83), even though the ML model used only clinicopathological biopsy features without MRI. This is important for settings where preoperative MRI is not routinely available.
Decision curve analysis at a threshold probability of 15% for ssEPE showed that using the ML model would allow 14 additional patients per 100 cases to safely undergo ipsilateral nerve-sparing surgery compared to a treat-all strategy, versus 8 additional patients with logistic regression and only 1 additional patient with the baseline model. This represents a meaningful clinical gain in preserved sexual and urinary function.
Applying the 15% cutoff to the combined dataset, the ML model correctly identified 308 of 695 non-ssEPE lobes (44%) as low enough risk to consider nerve-sparing, compared to 257 (37%) with logistic regression and 195 (28%) with the baseline model. This means the ML model enables approximately 113 more nerve-sparing procedures per 695 cases than the baseline standard without sacrificing sensitivity for detecting true EPE cases.
The three most important predictive features identified by SHAP were PSA, maximum percentage core involvement, and perineural invasion, all consistent with established clinical knowledge about EPE risk factors. This alignment with clinical intuition validates the model's logic and helps build physician trust.
Partial dependence plots revealed important non-linear relationships: PSA showed a logarithmic effect where risk rises sharply at low PSA values but plateaus beyond PSA 10, while maximum core involvement and percentage Gleason pattern 4/5 showed approximately linear associations with ssEPE risk. These nuanced patterns would be missed by logistic regression, which assumes linear relationships.
This study is the first to incorporate quantitative percentage of Gleason pattern 4/5, perineural invasion, and detailed site-specific biopsy findings into an ssEPE prediction model. The base biopsy region was the highest-ranked site-specific feature, and base findings outranked worst Gleason grade group in importance, reinforcing published evidence that a positive basal core is an independent predictor of EPE due to the prostate's anatomical proximity to surrounding neurovascular structures at the base.
A practical strength of this model is accessibility: all 11 features are part of the standard diagnostic workup for localized prostate cancer in Canada and most developed countries, requiring no additional testing beyond routine biopsy. The model has been deployed as a publicly available web application at streamlit.io, allowing any clinician with an internet connection to calculate patient-specific ssEPE probability and view a SHAP-based explanation of the prediction.
Key limitations include the absence of MRI features due to limited availability in the study cohort, exclusion of patients with incomplete records (11% of training cohort), and restriction to patients who had not received neoadjuvant therapy. Future work will incorporate PI-RADS MRI findings as preoperative MRI becomes routine in Canada, potentially further improving predictive accuracy.
From a methodological perspective, SHAP is a post-hoc explainability method with known limitations related to consistency and uncertainty in explanations. Researchers and clinicians should treat SHAP explanations as informative guidance rather than ground truth, and the model requires additional external validation in more diverse geographic and ethnic populations before widespread adoption.
This study demonstrates that a machine learning model using only routine biopsy-derived clinicopathological features can outperform established ssEPE prediction models and approach the performance of MRI-based models, while also being fully explainable. This combination of accuracy and interpretability represents an important advance for AI-assisted surgical planning.
The deployment as a public web application makes this tool immediately accessible to urologists in both academic and community settings, including resource-limited environments without routine preoperative MRI. The ability to generate a patient-specific probability estimate along with an explanation of the driving factors enables more informed shared decision-making between physicians and patients regarding nerve-sparing surgery.
More broadly, this study illustrates how explainable AI can increase clinical trust in machine learning predictions. Rather than asking clinicians to accept an opaque model's recommendation, the SHAP-based explanation shows which features drove the prediction for each individual patient, allowing clinicians to verify whether the model's reasoning makes clinical sense before acting on it.
The work aligns with a growing consensus that clinical AI tools must not only be accurate but also transparent, interpretable, and aligned with clinical workflows to achieve real-world adoption. Future work integrating MRI features, larger multi-institutional datasets, and prospective validation will be essential to establish this type of explainable AI model as a routine component of pre-prostatectomy surgical planning.