cobra | R Documentation |
The function cobra
implements the COBRA (COmBined Regression Alternative),
an aggregation method for combining predictions from multiple individual learners.
This method aims to tune key parameters for achieving optimal predictions
by averaging the target values of similar candidates in the training dataset's predictions.
Only the training points that are sufficiently similar to the test point
(based on the proximity threshold epsilon
) are used for prediction.
If no suitable training points are found, the function returns NA
.
cobra(x, y, tune = "epsilon", k_folds = NULL, eps = NULL)
x |
|
y |
|
tune |
|
k_folds |
|
eps |
|
An object of class cobra
containing the training data, target values, and chosen parameters.
Biau, G., Fischer, A., Guedj, B., & Malley, J. D. (2014). COBRA: A combined regression strategy. The Journal of Multivariate Analysis 46:18-28
# Example usage
set.seed(123)
x_train <- data.frame(a = runif(10L), b = runif(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", k_folds = 2)
# Make predictions on new data
set.seed(156)
x_new <- data.frame(a = runif(5L), b = runif(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.