prediction: Calculate Shapley weights for test data In shapr: Prediction Explanation with Dependence-Aware Shapley Values

Description

This function should only be called internally, and not be used as a stand-alone function.

Usage

 1 prediction(dt, prediction_zero, explainer)

Arguments

 dt data.table prediction_zero Numeric. The value to use for phi_0. explainer An object of class explainer. See shapr.

Details

If dt does not contain three columns called id, id_combination and w the function will fail. id represents a unique key for a given test observation, and id_combination is a unique key for which feature combination the row represents. w represents the Shapley value of feature combination given by id_combination. In addition to these three columns, dt should also have columns which matches the variables used when training the model.

I.e. you have fitted a linear model using the features x1, x2 and x3, and you want to explain 5 test observations using the exact method, i.e. setting exact = TRUE in shapr, the following properties should be satisfied

1. colnames(dt) equals c("x1", "x2", "x3", "id", "id_combination", ""w)

2. dt[, max(id)] equals the number of test observations

3. dt[, min(id)] equals 1L.

4. dt[, max(id_combination)] equals 2^m where m equals the number of features.

5. dt[, min(id_combination)] equals 1L.

6. dt[, type(w)] equals double.

Value

An object of class c("shapr", "list"). For more details see explain.

Author(s)

Nikolai Sellereite

shapr documentation built on Jan. 28, 2021, 5:06 p.m.