predict.prunedadaStump: Predict from a 'prunedadaStump' object

Description Usage Arguments Value Examples

View source: R/predict.prunedadaStump.R

Description

Predict from a prunedadaStump object

Usage

1
2
## S3 method for class 'prunedadaStump'
predict(stump.model, newdata)

Arguments

stump.model

object of class prunedadaStump

newdata

Data to be fit

Value

A vector of length nrow(newdata) expressing the probability of ocurrence of the event modelled.

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.