Skip to content

Aggregate local_interactions to estimate shap with interactions #91

Open
@aruaud

Description

@aruaud

Hi,
Thanks for the package! I was wondering how is the variable order set when calculating the local interactions and if there could be a way to randomize that order to repeat the measure of the contribution for different orders (and get an estimation of the contribution closer to what SHAP would output)?
I tried passing different orders of variables to local_interactions(..., order =) but it does not change anything, and so I don't know if I am missing a step.. ?

Script example:

# get the variable names and interactions
tmp <- colnames(X)
tmp <- combn(tmp, m = 2)
tmp <-unlist(lapply(asplit(tmp, MARGIN = 2), paste, collapse = ':'))
varN <- c(colnames(X), tmp)

# create different orders
var_orders <- list()
for (i in 1:5){
    set.seed(i)
    var_orders[[i]] <- sample(varN)
}

# get the contributions for different orders
res <- list()
i <- 1
for (vo in var_orders){
    res[[i]] <- local_interactions(new_observation = X[1,],x = explain_rf, interaction_preference = 10, var_orders = vo)
    i <- i+1
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature 💡New feature or enhancement request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions