predict.jous {JOUSBoost} | R Documentation |
Create predictions
Description
Makes a prediction on new data for a given fitted jous
model.
Usage
## S3 method for class 'jous'
predict(object, X, type = c("response", "prob"), ...)
Arguments
object |
An object of class |
X |
A design matrix of predictors. |
type |
The type of prediction to return. If |
... |
... |
Value
Returns a vector of class predictions if type="response"
, or a
vector of class probabilities p(y=1|x)
if type="prob"
.
Examples
## Not run:
# Generate data from Friedman model #
set.seed(111)
dat = friedman_data(n = 500, gamma = 0.5)
train_index = sample(1:500, 400)
# Apply jous to adaboost classifier
class_func = function(X, y) adaboost(X, y, tree_depth = 2, n_rounds = 100)
pred_func = function(fit_obj, X_test) predict(fit_obj, X_test)
jous_fit = jous(dat$X[train_index,], dat$y[train_index], class_func,
pred_func, keep_models=TRUE)
# get class prediction
yhat = predict(jous_fit, dat$X[-train_index, ])
# get probability estimate
phat = predict(jous_fit, dat$X[-train_index, ], type="prob")
## End(Not run)
[Package JOUSBoost version 2.1.0 Index]