| interpret | R Documentation |
Implements native permutation VI, PDP/ICE/ALE, SHAP approximations, local surrogate explanations, interaction strength, and global surrogate models.
interpret(
fit,
data,
formula = fit$formula,
method = c("vip", "permute", "pdp", "ice", "ale", "local", "lime", "shap",
"local_model", "interaction", "surrogate", "profile", "ceteris_paribus",
"calibration", "dca"),
features = NULL,
type = NULL,
metric = NULL,
importance_type = c("permute", "model", "auto"),
compare = c("difference", "ratio"),
keep = TRUE,
k = NULL,
gower_power = NULL,
class_level = NULL,
pos_level = NULL,
newdata = NULL,
nsim = NULL,
nsamples = NULL,
grid = NULL,
seed = NULL,
bins = 10,
strategy = c("quantile", "uniform"),
ncores = NULL,
...
)
fit |
A |
data |
Reference data (typically training set). |
formula |
Optional formula (defaults to |
method |
One of "vip","permute","pdp","ice","ale","local","lime", "shap","local_model","interaction","surrogate","profile", "ceteris_paribus", or "calibration". |
features |
Optional subset of features; defaults to all predictors. |
type |
Prediction scale: regression -> "response"; classification -> "prob" or "class". |
metric |
Loss/score for importance (reg: rmse/mae/mse/medae/mape/rsq; cls: accuracy/precision/recall/specificity/f1/balanced_accuracy/logloss/brier/ece/mce/auc/auc_weighted). |
importance_type |
Importance engine for |
compare |
How to compare baseline and perturbed performance for
importance: |
keep |
Keep per-repetition raw importance scores when |
k |
Sparsity target for local surrogate fits ( |
gower_power |
Exponent applied to native similarity weights when constructing the local neighborhood. |
class_level |
Target class for multiclass/local prob explanations. |
pos_level |
Alias for binary positive class (second level default). |
newdata |
Single-row data frame for local/SHAP explanations; defaults to first row of |
nsim |
Number of Monte Carlo simulations (importance/SHAP) or repetitions. |
nsamples |
Row subsample for speed (reference/background set). |
grid |
Optional list of grids per feature for PDP/ICE/ALE. |
seed |
Optional seed for determinism. |
bins |
Number of bins for calibration diagnostics. |
strategy |
Binning strategy for calibration diagnostics. |
ncores |
Optional number of CPU cores used to parallelize the
per-observation SHAP computation ( |
... |
Additional method-specific args. |
An interpretation object whose class depends on method.
Returned objects contain computed explanation values and metadata used
for printing, summarizing, and plotting.
fit_obj <- fit(
mpg ~ wt + hp + disp,
data = mtcars,
model = "rpart",
spec = list(cp = 0.01, minsplit = 5)
)
vi <- interpret(
fit = fit_obj,
data = mtcars,
method = "permute",
features = c("wt", "hp"),
nsim = 2,
metric = "rmse"
)
vi$result$scores
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.