extract_predict_survshap function

Extract Local SurvSHAP(t) from Global SurvSHAP(t)

Extract Local SurvSHAP(t) from Global SurvSHAP(t)

Helper function to extract local SurvSHAP(t) explanation from global one. Can be can be useful for creating SurvSHAP(t) plots for single observations.

extract_predict_survshap(aggregated_survshap, index)

Arguments

  • aggregated_survshap: an object of class aggregated_surv_shap containing the computed global SHAP values
  • index: a numeric value, position of an observation to be extracted in the result of global explanation

Returns

An object of classes c("predict_parts_survival", "surv_shap"). It is a list with the element result containing the results of the explanation.

Examples

veteran <- survival::veteran rsf_ranger <- ranger::ranger( survival::Surv(time, status) ~ ., data = veteran, respect.unordered.factors = TRUE, num.trees = 100, mtry = 3, max.depth = 5 ) rsf_ranger_exp <- explain( rsf_ranger, data = veteran[, -c(3, 4)], y = survival::Surv(veteran$time, veteran$status), verbose = FALSE ) ranger_global_survshap <- model_survshap( explainer = rsf_ranger_exp, new_observation = veteran[ c(1:4, 17:20, 110:113, 126:129), !colnames(veteran) %in% c("time", "status") ] ) local_survshap_1 <- extract_predict_survshap(ranger_global_survshap, index = 1) plot(local_survshap_1)
  • Maintainer: Mikołaj Spytek
  • License: GPL (>= 3)
  • Last published: 2023-10-24