model_checker: Check that the type of model is supported by the explanation...

Description Usage Arguments Details Value Examples

View source: R/models.R

Description

The function checks whether the model given by x is supported. If x is not a supported model the function will return an error message, otherwise it return NULL (meaning all types of models with this class is supported)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
model_checker(x)

## Default S3 method:
model_checker(x)

## S3 method for class 'lm'
model_checker(x)

## S3 method for class 'glm'
model_checker(x)

## S3 method for class 'ranger'
model_checker(x)

## S3 method for class 'gam'
model_checker(x)

## S3 method for class 'xgb.Booster'
model_checker(x)

Arguments

x

Model object for the model to be explained.

Details

See predict_model for more information about what type of models shapr currently support.

Value

Error or NULL

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
if (requireNamespace("MASS", quietly = TRUE)) {
  # Load example data
  data("Boston", package = "MASS")
  # Split data into test- and training data
  x_train <- head(Boston, -3)
  # Fit a linear model
  model <- lm(medv ~ lstat + rm + dis + indus, data = x_train)

  # Checking the model object
  model_checker(x = model)
}

shapr documentation built on Jan. 28, 2021, 5:06 p.m.