predict.adaboost {JOUSBoost} | R Documentation |
Create predictions from AdaBoost fit
Description
Makes a prediction on new data for a given fitted adaboost
model.
Usage
## S3 method for class 'adaboost'
predict(object, X, type = c("response", "prob"),
n_tree = NULL, ...)
Arguments
object |
An object of class |
X |
A design matrix of predictors. |
type |
The type of prediction to return. If |
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"
.
Note
Probabilities are estimated according to the formula:
p(y=1| x) = 1/(1 + exp(-2*f(x)))
where f(x)
is the score function produced by AdaBoost. See
Friedman (2000).
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
## 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")
## End(Not run)