shap.utils.partition_tree_shuffle

shap.utils.partition_tree_shuffle(indexes: NDArray[Any], index_mask: NDArray[bool], partition_tree: NDArray[Any]) None

Randomly shuffle the indexes in a way that is consistent with the given partition tree.

Parameters:
indexes: np.array

The output location of the indexes we want shuffled. Note that len(indexes) should equal index_mask.sum().

index_mask: np.array

A bool mask of which indexes we want to include in the shuffled list.

partition_tree: np.array

The partition tree we should follow.