highmlr_explain: Time-dependent SHAP explanations for a highmlr_fit...

View source: R/companions.R

highmlr_explainR Documentation

Time-dependent SHAP explanations for a highmlr_fit (SurvSHAP(t))

Description

Computes SurvSHAP(t) attributions (Krzyzinski et al., 2023) – SHAP values that vary with follow-up time – for the top features in a fitted 'highmlr_fit'. Returns the survex explainer, per-feature aggregated importance, and a plotting helper.

Usage

highmlr_explain(
  fit,
  new_data = NULL,
  top_n = 10L,
  times = NULL,
  method = c("survshap", "permutation", "break_down"),
  n_explain = 25L,
  seed = NULL,
  ...
)

## S3 method for class 'highmlr_explain'
print(x, n = 10, ...)

## S3 method for class 'highmlr_explain'
plot(x, top_n = 10, ...)

Arguments

fit

A 'highmlr_fit' object with a stored model.

new_data

Data on which to compute explanations.

top_n

Number of top features to explain (default 10).

times

Optional numeric vector of time points at which SHAP values are computed. Defaults to a 20-point grid spanning the observed time range.

method

SHAP method passed through to 'survex'. Default '"survshap"' (time-dependent). Other options: '"permutation"', '"break_down"'.

n_explain

How many test rows to compute SHAP for. Default 25 (SHAP is expensive; full-cohort computation is rarely needed).

seed

Optional integer for reproducibility of subsampling.

...

Passed to 'survex::model_survshap()' or 'survex::explain_survival()'.

x

A 'highmlr_explain' object.

n

Number of top features to print (default 10).

Value

A list with class 'highmlr_explain' containing: * 'explainer' – the 'survex' explainer object * 'survshap' – the time-dependent SHAP object (if applicable) * 'top_features' – the top features table from the fit * 'aggregated' – tibble of mean absolute SHAP per feature, averaged across time and explained rows


highMLR documentation built on May 23, 2026, 5:07 p.m.