gazer: Create a QSHAP Tree Explainer

View source: R/tree_explainer.R

gazerR Documentation

Create a QSHAP Tree Explainer

Description

Creates an explainer object for computing feature-specific Shapley values from a trained tree ensemble model. Supports XGBoost, LightGBM, and CatBoost models.

Usage

gazer(model, max_depth = NULL, base_score = NULL, ...)

Arguments

model

A model object of class xgboost or xgb.Booster from xgboost, class lgb.Booster from lightgbm, or class catboost.Model from catboost

max_depth

Maximum depth of trees, extracted from model by default.

base_score

Base score for predictions, extracted from model by default.

...

Additional arguments, for future use

Value

A class of qshap_tree_explainer object containing the model information and preprocessed tree structures for fast Shapley value computation

Examples

library(xgboost)
set.seed(42)
n <- 100
p <- 100
X <- matrix(rnorm(n * p), nrow = n, ncol = p)
y <- X[, 1] - X[, 2] + rnorm(n, sd = 0.2)
model <- xgboost(X, y, nrounds = 15, max_depth = 2, verbosity = 0, nthread = 1)
explainer <- gazer(model)


qshap documentation built on Aug. 23, 2026, 5:11 p.m.