Learn R Programming

xtune (version 2.0.0)

predict_xtune: Model predictions based on fitted xtune object

Description

predict_xtune produces predicted values fitting an xtune model to a new dataset

Usage

predict_xtune(object, newX, type = c("response", "class"), ...)

Value

A vector of predictions

Arguments

object

Fitted 'xtune' model object.

newX

Matrix of values at which predictions are to be made.

type

Type of prediction required. For "linear" models it gives the fitted values. Type "response" gives the fitted probability scores of each category for "binary" or "multiclass" outcome. Type "class" applies to "binary" or "multiclass" models, and produces the class label corresponding to the maximum probability.

...

Not used

Details

coef and predict methods are provided as a convenience to extract coefficients and make prediction. predict_xtune simply calculate the predicted value using the estimated coefficients returned by xtune.

See Also

xtune, coef_xtune

Examples

Run this code

## If no Z provided, perform Empirical Bayes tuning
## simulate linear data
set.seed(9)
data(example)
X <- example$X
Y <- example$Y
Z <- example$Z

# \donttest{
fit.eb <- xtune(X,Y)
coef_xtune(fit.eb)
predict_xtune(fit.eb,X)
# }


## Feature specific shrinkage based on external information Z:

## simulate multi-categorical data
data(example.multiclass)
X <- example.multiclass$X
Y <- example.multiclass$Y
Z <- example.multiclass$Z
# \donttest{
fit <- xtune(X,Y,Z,family = "multiclass")


## Coef and predict methods
coef_xtune(fit)
predict_xtune(fit,X, type = "class")
# }

Run the code above in your browser using DataLab