pruneTree: Merge stumps with repeated conditions

Description Usage Arguments Value Examples

View source: R/pruneTree.R

Description

In order to reduce execution times, stumps with the same condition are collapsed. If a pruned model is used, n.iter can no longer be specified and all the stumps are used.

Usage

1
pruneTree(stump.model)

Arguments

stump.model

Object of class "adaStump" to be reduced.

Value

An item of class prunedadaStump containing the following:

model

a data.frame describing the pruned stumps

type

Type of ada execution performed.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#Load Iris
data(iris)

#Create Variable is Iris as numerical
iris$isSetosa <- as.numeric(iris$Species == "setosa")

#Split sample in 70 train - 30 test
train.ind <- sample(nrow(iris), nrow(iris) * 0.7)

#Train model. For obvious reasons, Species variable is not included in the fit
fit <- adaStump(isSetosa ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, iris[train.ind,], 
                type = "discrete", iter = 10, nu = 0.05, bag.frac = 0.6)
                
#Prune Tree and predict

fit_pruned <- pruneTree(fit)
predict(fit_pruned,iris[-train.ind,])

nivangio/adaStump documentation built on May 23, 2019, 7:06 p.m.