predict.jous: Create predictions

Description Usage Arguments Value Examples

View source: R/jous.R

Description

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

Usage

1
2
## S3 method for class 'jous'
predict(object, X, type = c("response", "prob"), ...)

Arguments

object

An object of class jous returned by the jous 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.

...

...

Value

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

Examples

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

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