trainsetBias: Trainset Bias

Description Usage Arguments Details Value Functions References See Also Examples

View source: R/trainsetBias.R

Description

For a tree in the forest, trainset bias is the prediction of its root node, or the unconditional prediction of the tree, or the average response of the samples used to train the tree.

Usage

1
2
3
trainsetBiasTree(tidy.RF, tree)

trainsetBias(tidy.RF)

Arguments

tidy.RF

A tidy random forest. The random forest to extract train set bias from.

tree

An integer. The index of the tree to look at.

Details

For a forest, the trainset bias is simply the average trainset bias across all trees. This is because the prediction of a forest is the average of the predictions of its trees.

Together with featureContrib(Tree), they can decompose the prediction by feature importance:

prediction(MODEL, X) = trainsetBias(MODEL) + featureContrib_1(MODEL, X) + ... + featureContrib_p(MODEL, X),

where MODEL can be either a tree or a forest.

Value

A matrix. The content depends the type of the response.

Functions

References

Interpreting random forests http://blog.datadive.net/interpreting-random-forests/

Random forest interpretation with scikit-learn http://blog.datadive.net/random-forest-interpretation-with-scikit-learn/

See Also

featureContrib

Examples

1
2
3
4
5
library(ranger)
rfobj <- ranger(Species ~ ., iris, keep.inbag=TRUE)
tidy.RF <- tidyRF(rfobj, iris[, -5], iris[, 5])
trainsetBiasTree(tidy.RF, 1)
trainsetBias(tidy.RF)

tree.interpreter documentation built on March 26, 2020, 6:21 p.m.