View source: R/predict.cobra.R
predict.cobra | R Documentation |
#' The predict.cobra
function makes predictions on new data using a trained COBRA object.
## S3 method for class 'cobra'
predict(object, data, ...)
object |
An object of class "cobra" created by the |
data |
A |
... |
Additional arguments (currently not used). |
A vector of predictions for the new data.
# Example usage
set.seed(123)
x_train <- data.frame(a = rnorm(10L), b = rnorm(10L))
y_train <- sample(0L:1L, size = 10L, replace = TRUE)
# Train the model with epsilon optimization
cobra_model <- cobra(x = x_train, y = y_train, tune = "epsilon")
# Make predictions on new data
set.seed(156)
x_new <- data.frame(a = rnorm(5L), b = rnorm(5L))
prediction <- predict(object = cobra_model, data = x_new)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.