Description Usage Arguments Value Examples
View source: R/predict.prunedadaStump.R
Predict from a prunedadaStump
object
1 2 | ## S3 method for class 'prunedadaStump'
predict(stump.model, newdata)
|
stump.model |
object of class |
newdata |
Data to be fit |
A vector of length nrow(newdata)
expressing the probability of ocurrence of the event modelled.
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.