Learn R Programming

shapr (version 0.2.2)

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

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

model_checker(x)

# S3 method for default model_checker(x)

# S3 method for lm model_checker(x)

# S3 method for glm model_checker(x)

# S3 method for ranger model_checker(x)

# S3 method for gam model_checker(x)

# S3 method for xgb.Booster model_checker(x)

Value

Error or NULL

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.

Examples

Run this code
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)
}

Run the code above in your browser using DataLab