Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

vivi

vivi


Description

Creates a matrix displaying variable importance on the diagonal and variable interaction on the off-diagonal.

Usage

vivi(
  data,
  fit,
  response,
  gridSize = 50,
  importanceType = NULL,
  nmax = NULL,
  reorder = TRUE,
  class = 1,
  predictFun = NULL
)

Arguments

data

Data frame used for fit.

fit

A supervised machine learning model, which understands condvis2::CVpredict

response

The name of the response for the fit.

gridSize

The size of the grid for evaluating the predictions.

importanceType

One of either "%IncMSE" or "IncNodePurity" for use with randomForest. Or set to equal "agnostic" to override embedded importance measures and return agnostic importance values.

nmax

Maximum number of data rows to consider.

reorder

If TRUE (default) uses DendSer to reorder the matrix of interactions and variable importances.

class

Category for classification, a factor level, or a number indicating which factor level.

predictFun

Function of (fit, data) to extract numeric predictions from fit. Uses condvis2::CVpredict by default, which works for many fit classes.

Value

A matrix of interaction values, with importance on the diagonal.

Examples

aq <- na.omit(airquality)
f <- lm(Ozone ~ ., data = aq)
m <- vivi(fit = f, data = aq, response = "Ozone") # as expected all interactions are zero
viviHeatmap(m)


# Run an mlr ranger model:
library(mlr3)
library(mlr3learners)
library(ranger)
aq <- na.omit(airquality)
aq_Task <- TaskRegr$new(id = "airQ", backend = aq, target = "Ozone")
aq_lrn <- lrn("regr.ranger", importance = "permutation")
aq_fit <- aq_lrn$train(aq_Task)

m <- vivi(fit = aq_fit, data = aq, response = "Ozone")
viviHeatmap(m)


library(ranger)
rf <- ranger(Species ~ ., data = iris, importance = "impurity")
vivi(fit = rf, data = iris, response = "Species")

vivid

Variable Importance and Variable Interaction Displays

v0.1.0
GPL (>= 2)
Authors
Alan Inglis [aut, cre], Andrew Parnell [aut], Catherine Hurley [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.