Assign prediction samples to explanation paths
Source:R/explanation-paths.R
assign_explanation_paths.RdProject user or held-out prediction samples onto explanation paths that were previously defined from training SHAP values. Prediction samples never redefine the paths. Each sample is first classified as Sensitive or Resistant using the same target-specific cutoff used for path calculation, then assigned to the supported path in that class with the smallest mean SHAP-profile distance to its training samples.
Arguments
- paths
An object returned by
calculate_explanation_paths().- models
A named fitted model list after
add_powerup_predictions().- targets
Optional character vector of analyzed targets.
NULLassigns samples for every target available inpaths.- samples
Optional character vector of prediction sample names.
NULLuses every prediction sample. Samples may originate fromuser_matrix,test_cell_lines, or both inprepare_powerup_data().- verbose
If
TRUE, report progress.
Value
A tibble with one row per target and prediction sample. Similarity is
1 - mean distance to training samples in the assigned path, and
assignment_margin is the second-best minus best path distance. These are
descriptive assignment measures, not calibrated probabilities.
Examples
if (FALSE) { # \dontrun{
paths <- calculate_explanation_paths(models)
models_pred <- add_powerup_predictions(models, prepared)
assignments <- assign_explanation_paths(paths, models_pred)
} # }