predict.model_unified {treeshap}R Documentation

Predict

Description

Predict using unified_model representation.

Usage

## S3 method for class 'model_unified'
predict(object, x, ...)

Arguments

object

Unified model representation of the model created with a (model).unify function. model_unified.object

x

Observations to predict. A data.frame or matrix with the same columns as in the training set of the model.

...

other parameters

Value

a vector of predictions.

Examples


library(gbm)
data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
data['value_eur'] <- fifa20$target
gbm_model <- gbm::gbm(
  formula = value_eur ~ .,
  data = data,
  distribution = "laplace",
  n.trees = 20,
  interaction.depth = 4,
  n.cores = 1)
  unified <- gbm.unify(gbm_model, data)
  predict(unified, data[2001:2005, ])
  

[Package treeshap version 0.3.1 Index]