predict.cobra: Predict Using COBRA object

View source: R/predict.cobra.R

predict.cobraR Documentation

Predict Using COBRA object

Description

#' The predict.cobra function makes predictions on new data using a trained COBRA object.

Usage

## S3 method for class 'cobra'
predict(object, data, ...)

Arguments

object

An object of class "cobra" created by the cobra function.

data

A data.frame of new data, where rows are observations and columns are predictions from individual learners. Use NA for missing predictions.

...

Additional arguments (currently not used).

Value

A vector of predictions for the new data.

Examples

# 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)

fuseMLR documentation built on April 3, 2025, 8:49 p.m.