SurvSHAP(t): Time-dependent explanations of machine learning survival models

Mateusz Krzyzinski, Mikolaj Spytek, Hubert Baniecki, Przemyslaw Biecek

Introduction

Survival analysis is a critical statistical tool used to predict the time until an event occurs, such as patient mortality in healthcare or mechanical failure in engineering. While traditional models like the Cox Proportional Hazards (CPH) model offer high interpretability, they often fall short when dealing with complex, non-linear relationships. Modern machine learning (ML) alternatives, including Random Survival Forests (RSF) and DeepSurv, provide superior predictive accuracy but operate as "black boxes," hindering their adoption in high-stakes environments.

Existing Explainable AI (XAI) frameworks like SHAP or LIME typically provide static importance scores. However, in survival analysis, a feature's impact often evolves over time. For instance, a specific biomarker might be a strong predictor of short-term survival but lose its relevance for long-term outcomes. SurvSHAP(t), developed by researchers at the Warsaw University of Technology, addresses this gap by providing the first model-agnostic explanation method that explicitly accounts for the time dimension.

Methodology

SurvSHAP(t) generalizes the SHapley Additive exPlanations (SHAP) framework to handle functional outputs. Instead of explaining a single scalar value, it explains the entire predicted survival function $\hat{S}(t, x)$.

Overview of the SurvSHAP(t) framework, illustrating the pipeline from model prediction to time-dependent feature attributions and aggregated importance.

The framework is built on several key principles:

  1. Functional Output: It calculates a Shapley value for every feature at every time point $t$, resulting in a "contribution curve" for each variable.
  2. Local Accuracy: The method satisfies the efficiency property from game theory. At any given time $t$, the sum of all feature attributions, plus a baseline average survival function, exactly equals the model's predicted survival probability.
  3. Aggregation: To simplify interpretation, the absolute values of these curves can be integrated over time to produce a "local variable importance" ranking.

Because it is model-agnostic, SurvSHAP(t) can be applied to any survival model that outputs a survival function.

Experimental Setup

The researchers validated SurvSHAP(t) across three distinct scenarios:

  • Synthetic Data (EXP1): Designed with time-dependent hazards to test the tool's ability to detect variables with effects that change over time.
  • Glass-box Comparison: Using synthetic datasets where ground-truth variable importance was known via underlying Cox coefficients, allowing for a direct comparison against SurvLIME.
  • Real-World Medical Data: A heart failure dataset (299 patients, 12 features) was used to demonstrate clinical utility in understanding individual patient risks.

Results and Discussion

The experiments highlighted several advantages of SurvSHAP(t) over existing methods. A primary insight was the detection of "crossing effects," where a variable's influence shifts from positive to negative over time. While standard methods might average these effects to zero, SurvSHAP(t) captures the full temporal narrative.

Comparison of SurvSHAP(t) values for Random Survival Forest and Cox Proportional Hazards models, demonstrating how the tool captures different model behaviors over time.

In "glass-box" benchmarks, SurvSHAP(t) achieved a Kendall’s $\tau$ correlation of 0.917 with ground-truth rankings, significantly outperforming SurvLIME (0.763). Furthermore, SurvSHAP(t) maintained near-perfect local accuracy (errors $\approx 10^{-7}$), whereas SurvLIME often failed to reconstruct the model's original prediction. In the heart failure case study, the tool correctly identified "ejection fraction" and "serum creatinine" as critical predictors, aligning with medical literature while specifying the exact timeframes of their maximum impact.

Conclusion and Future Work

SurvSHAP(t) represents a significant step forward in making complex survival models interpretable. By providing time-dependent explanations, it offers a more nuanced view of feature importance than previously possible.

However, challenges remain. Like other SHAP-based methods, SurvSHAP(t) is computationally intensive due to the need for repeated model evaluations across multiple time points. Additionally, it assumes feature additivity, which may complicate the interpretation of models with high-order interactions. Future research will focus on developing global explanations by aggregating local SurvSHAP(t) results to understand model behavior across entire populations.

The source code for SurvSHAP(t) is available as an open-source Python library at https://github.com/MI2DataLab/survshap.

Summary updated

BibTeX
@article{krzyzinski2023survshap,
  author = {Mateusz Krzyzinski and Mikolaj Spytek and Hubert Baniecki and Przemyslaw Biecek},
  title = {{SurvSHAP(t): Time-dependent explanations of machine learning survival models}},
  journal = {Knowledge-Based Systems},
  year = {2023},
  doi = {10.1016/j.knosys.2022.110234},
}
Figure