vivi_interaction | R Documentation |
Compute pairwise interactions only (Friedman's H), without importance.
vivi_interaction(
data,
fit,
response,
nmax = 500,
gridSize = 50,
predictFun = NULL,
normalized = FALSE,
vars = NULL,
reorder = TRUE
)
data |
Data frame used for |
fit |
A supervised ML model understood by |
response |
Name of the response column in |
nmax |
Maximum number of rows to consider for grids. Default 500. Use all rows if |
gridSize |
Grid size for evaluating partial dependence. Default 50. |
predictFun |
Optional prediction function |
normalized |
Should H be normalised. Default FALSE. |
vars |
Optional character vector of feature names to restrict the calculation. |
reorder |
If TRUE, reorder the resulting matrix with |
Square interaction matrix with zero diagonal.
# Example 1 — interactions with a linear model
aq <- na.omit(airquality)
fit_lm <- lm(Ozone ~ ., data = aq)
int_mat <- vivi_interaction(data = aq, fit = fit_lm, response = "Ozone")
dim(int_mat); int_mat[1:3, 1:3]
# viviHeatmap(int_mat) # if you want to visualise interactions only
# Example 2 — classification with ranger
if (requireNamespace("ranger", quietly = TRUE)) {
library(ranger)
fit_rf <- ranger(Species ~ ., data = iris,
importance = "impurity", probability = TRUE)
vivi_interaction(data = iris, fit = fit_rf, response = "Species")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.