predict.conformalize.Rd
This function generates prediction intervals for new data using the fitted conformal model.
A conformalize object.
A data frame or matrix of new data for prediction.
The confidence level for the prediction intervals. Default is 0.95.
The method to use for prediction intervals. Options are "split" or "simulation".
The number of simulations to perform if using the "simulation" method. Default is 1000.
An optional seed for reproducibility.
Additional arguments to pass to the predict function.
A matrix with predictions and prediction intervals.
if (FALSE) { # \dontrun{
# Define fit and predict functions
fit_func <- function(formula, data, ...) stats::glm(formula, data = data, ...)
predict_func <- function(fit, newdata, ...) predict(fit, newdata, ...)
# Apply conformalize using the training data
conformal_model_boston <- misc::conformalize(
formula = medv ~ .,
data = train_data,
fit_func = fit_func,
predict_func = predict_func,
seed = 123
)
# Predict with split conformal method on the test data
predictions_boston <- predict(
conformal_model_boston,
newdata = test_data,
level = 0.95,
method = "split"
)
head(predictions_boston)
} # }