Description Usage Arguments Details Value Examples
This function calculates a table with influence of variables and interactions on the prediction of a given observation. It supports only xgboost models.
1 2 3 4 5 6 7 8 |
xgb_model |
a xgboost model. |
new_observation |
a new observation. |
data |
row from the original dataset with the new observation to explain (not one-hot-encoded).
The param above has to be set to merge categorical features.
If you dont wont to merge categorical features, set this parameter the same as |
type |
the learning task of the model. Available tasks: "binary" for binary classification or "regression" for linear regression. |
option |
if "variables", the plot includes only single variables, if "interactions", then only interactions. Default "interaction". |
baseline |
a number or a character "Intercept" (for model intercept). The baseline for the plot, where the rectangles should start. Default 0. |
The function contains code or pieces of code
from breakDown
code created by Przemysław Biecek
and xgboostExplainer
code created by David Foster.
an object of the broken class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library("EIX")
library("Matrix")
sm <- sparse.model.matrix(left ~ . - 1, data = HR_data)
library("xgboost")
param <- list(objective = "binary:logistic", max_depth = 2)
xgb_model <- xgboost(sm, params = param, label = HR_data[, left] == 1, nrounds = 25, verbose=0)
data <- HR_data[9,-7]
new_observation <- sm[9,]
wf <- waterfall(xgb_model, new_observation, data, option = "interactions")
wf
plot(wf)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.