extractRules {inTrees}R Documentation

Extract rules from a list of trees

Description

Extract rule conditions from a list of trees. Use functions RF2List/GBM2List to transform RF/GBM objects to list of trees.

Usage

extractRules(treeList, X, ntree = 100, maxdepth = 6, random = FALSE, digits = NULL)

Arguments

treeList

tree list

X

predictor variable matrix

ntree

conditions are extracted from the first ntree trees

maxdepth

conditions are extracted from the top maxdepth levels from each tree

random

the max depth for each tree is an integer randomly chosen between 1 and maxdepth

digits

digits for rounding

Value

a set of rule conditions

Examples

    library(RRF)
    data(iris)
    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,digits=4) # transform to R-executable rules
    ruleExec <- unique(ruleExec)

[Package inTrees version 1.4 Index]