predict.adaboost: Create predictions from AdaBoost fit

Description Usage Arguments Value Note References Examples

View source: R/adaboost.R

Description

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

Usage

1
2
3
## S3 method for class '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".

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## 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)

JOUSBoost documentation built on July 13, 2017, 1:03 a.m.