inTrees (version 1.2)

buildLearner: build a simplified tree ensemble learner (STEL)

Description

Build a simplified tree ensemble learner (STEL). Currently works only for classification problems.

Usage

buildLearner(ruleMetric, X, target, minFreq = 0.01)

Arguments

ruleMetric

a matrix including the conditions, predictions, and and metrics

X

predictor variable matrix

target

target variable

minFreq

minimum frequency of a rule condition in order to be included in STEL.

Value

a matrix including the conditions, prediction, and metrics, ordered by priority.

References

Houtao Deng, Interpreting Tree Ensembles with inTrees, technical report, 2014

Examples

Run this code
# NOT RUN {
data(iris)
library(RRF)
X <- iris[,1:(ncol(iris)-1)]
target <- iris[,"Species"] 
rf <- RRF(X,as.factor(target),ntree=100) # build an ordinary RF 
treeList <- RF2List(rf)
ruleExec <- extractRules(treeList,X)
ruleExec <- unique(ruleExec)
ruleMetric <- getRuleMetric(ruleExec,X,target) # measure rules
ruleMetric <- pruneRule(ruleMetric,X,target) # prune each rule
#ruleMetric <- selectRuleRRF(ruleMetric,X,target) # rule selection
learner <- buildLearner(ruleMetric,X,target)
pred <- applyLearner(learner,X)
read <- presentRules(learner,colnames(X)) # more readable format

# format the rule and metrics as a table in latex code
library(xtable)
print(xtable(read), include.rownames=FALSE)
print(xtable(ruleMetric[1:2,]), include.rownames=FALSE)

# }

Run the code above in your browser using DataCamp Workspace