Skip to contents

Project 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.

Usage

assign_explanation_paths(
  paths,
  models,
  targets = NULL,
  samples = NULL,
  verbose = TRUE
)

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. NULL assigns samples for every target available in paths.

samples

Optional character vector of prediction sample names. NULL uses every prediction sample. Samples may originate from user_matrix, test_cell_lines, or both in prepare_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)
} # }