Description Usage Arguments Value Examples
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.
1 | pruneTree(stump.model)
|
stump.model |
Object of class "adaStump" to be reduced. |
An item of class prunedadaStump containing the following:
model |
a data.frame describing the pruned stumps |
type |
Type of ada execution performed. |
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,])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.