Learn R Programming

pre (version 1.1.0)

RuleMats: Compute matrices that identify the rules

Description

This function computes the matrices that are needed to compute marginal Shapley values of a RuleSHAP model. These matrices check which points satisfy each of the subrules of each rule. They also check which predictors are involved in the definition of each rule.

Usage

RuleMats(rules, x_df)

Value

RulePredMat A matrix with as many rows as there are rules and as many columns as there are predictors. The \(j\)-th column has ones on the entries corresponding to rules that involve the \(j\)-th predictor, while all remaining entries are zeroes. Can be computed with the RuleMats function.

Rs a list of as many matrices as there are rules. The \(j\)-th element is a matrix corresponding to the \(j\)-th rule. Each of its columns corresponds to the 0-1 encoding of a subrule of the \(j\)-th rule, as observed in the data provided with input parameter x.

Arguments

rules

a character vector containing the rules to compute the matrices for

x_df

a dataframe containing the observations to compute the matrices for

Author

Giorgio Spadaccini