Learn R Programming

shapr (version 0.1.3)

model_type: Define type of model

Description

The function checks whether the model given by x is supported, and if it is a regression- or a classification model. If x is not a supported model the function will return an error message, otherwise it will return either "regression" or "classification".

Usage

model_type(x)

# S3 method for default model_type(x)

# S3 method for lm model_type(x)

# S3 method for glm model_type(x)

# S3 method for ranger model_type(x)

# S3 method for gam model_type(x)

# S3 method for xgb.Booster model_type(x)

Arguments

x

Model object for the model to be explained.

Value

Either "classification" or "regression".

Details

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

Examples

Run this code
# NOT RUN {
# 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)

# Writing out the defined model type of the object
model_type(x = model)
# }

Run the code above in your browser using DataLab