Learn R Programming

JOUSBoost (version 2.1.0)

predict.adaboost: Create predictions from AdaBoost fit

Description

Makes a prediction on new data for a given fitted adaboost model.

Usage

# S3 method for adaboost
predict(object, X, type = c("response", "prob"),
  n_tree = NULL, ...)

Arguments

object

An object of class adaboost returned by the adaboost function.

X

A design matrix of predictors.

type

The type of prediction to return. If type="response", a class label of -1 or 1 is returned. If type="prob", the probability \(p(y = 1 | x)\) is returned.

n_tree

The number of trees to use in the prediction (by default, all them).

...

Value

Returns a vector of class predictions if type="response", or a vector of class probabilities \(p(y=1|x)\) if type="prob".

References

Friedman, J., Hastie, T. and Tibshirani, R. (2000). Additive logistic regression: a statistical view of boosting (with discussion), Annals of Statistics 28: 337-307.

Examples

Run this code
# NOT RUN {
# Generate data from the circle model
set.seed(111)
dat = circle_data(n = 500)
train_index = sample(1:500, 400)

ada = adaboost(dat$X[train_index,], dat$y[train_index], tree_depth = 2,
               n_rounds = 100, verbose = TRUE)
# get class prediction
yhat = predict(ada, dat$X[-train_index, ])
# get probability estimate
phat = predict(ada, dat$X[-train_index, ], type="prob")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab