r2: Compute feature importances using a Shapley variance...

Description Usage Arguments Value

View source: R/r2.R

Description

This function uses pre-computed Shapley values to decompose the overall model R^2 into feature-level attributions of variance explained using the formulation of Redell (2019) arXiv:1908.09718.

Usage

1
r2(shap, y, intercept, scale = c("r2", "1"))

Arguments

shap

A matrix or data.frame of Shapley values. The dimensions should be 'number of instances' by 'number of features'. The predicted outcome for each instance, used in the R^2 caluclation, is the row sum of Shapley values across columns + the user-supplied intercept.

y

A length(nrow(shap) numeric vector or 1-column matrix or data.frame with the outcome being predicted.

intercept

A length-1 numeric vector giving the model's average prediction. The intercept is returned in shapFlex().

scale

The scaling of the feature importances. r2 (default) scales feature-level importances to the overall model R^2 while 1 scales feature importances along a 0 to 1 scale.

Value

A data.frame of the feature importances with the model's global R^2 ('r2'), the feature-level importances or attribution of variance explained ('r2_shap'), and the proportion of variance between the baseline or intercept-only model and the final model that can be uniquely ascribed to a given feature ('sigma_unique').


nredell/shapFlex documentation built on June 11, 2020, 4:40 a.m.