Learn R Programming

uplift (version 0.3.5)

varImportance: Extract Variable Importance from upliftRF or ccif Fitted Objects

Description

This is the extractor function for variable importance of predictors.

Usage

"varImportance"(x, n.trees = x$ntree, plotit = TRUE, normalize = TRUE, ...)

Arguments

x
an object of class upliftRF or ccif.
n.trees
number of trees used in the prediction; The default is x$ntree.
plotit
plot variable importance?
normalize
if set to TRUE, the importance is scaled to add up to 100.
...
additional arguments passed to barplot.

Value

A numeric vector with the variable importance.

Details

At each split in each tree, the improvement in the split-criterion is the importance measure attributed to the splitting variable, and is accumulated over all the trees in the forest separately for each variable.

References

Guelman, L., Guillen, M., and Perez-Marin A.M. (2013). Uplift random forests. Cybernetics & Systems, forthcoming.

Examples

Run this code
library(uplift)

### simulate data for uplift modeling

set.seed(123)
dd <- sim_pte(n = 1000, p = 20, rho = 0, sigma =  sqrt(2), beta.den = 4)
dd$treat <- ifelse(dd$treat == 1, 1, 0) 

### fit uplift random forest

fit1 <- upliftRF(y ~ X1 + X2 + X3 + X4 + X5 + X6 + trt(treat),
                 data = dd, 
                 mtry = 3,
                 ntree = 100, 
                 split_method = "KL",
                 minsplit = 200, 
                 verbose = TRUE)
print(fit1)

### get variable importance 

varImportance(fit1, plotit = TRUE, normalize = TRUE)

Run the code above in your browser using DataLab