An R re-implementation of the treeinterpreter package on PyPI. Each prediction can be decomposed as 'prediction = bias + feature_1_contribution + ... + feature_n_contribution'. This decomposition is then used to calculate the Mean Decrease Impurity (MDI) and Mean Decrease Impurity using out-of-bag samples (MDI-oob) feature importance measures based on the work of Li et al. (2019) arXiv:1906.10845.
To install the CRAN version, run
install.packages('tree.interpreter')
To install the latest development version, run
devtools::install_github('nalzok/tree.interpreter')
macOS users might want to follow the set up instructions by The Coatless Professor to minimize operational headaches and maximize computational performance.
For example, you can calculate the state-of-the-art MDI-oob feature importance
measure for ranger. See vignette('MDI', package='tree.interpreter')
for
more information.
library(ranger)
library(tree.interpreter)
set.seed(42L)
rfobj <- ranger(mpg ~ ., mtcars, keep.inbag = TRUE)
tidy.RF <- tidyRF(rfobj, mtcars[, -1], mtcars[, 1])
mtcars.MDIoob <- MDIoob(tidy.RF, mtcars[, -1], mtcars[, 1])
mtcars.MDIoob
This package companies the paper A Debiased MDI Feature Importance Measure for Random Forests.