View source: R/borg_wrappers.R
| borg_trainControl | R Documentation |
A guarded version of caret::trainControl() that validates CV settings
against data dependencies.
borg_trainControl(
data,
method = "cv",
number = 10,
coords = NULL,
time = NULL,
groups = NULL,
target = NULL,
allow_override = FALSE,
...
)
data |
A data frame. Required for dependency checking. |
method |
Character. Resampling method. |
number |
Integer. Number of folds or iterations. |
coords |
Character vector. Coordinate columns for spatial check. |
time |
Character. Time column for temporal check. |
groups |
Character. Group column for clustered check. |
target |
Character. Target variable. |
allow_override |
Logical. Allow random CV despite dependencies. |
... |
Additional arguments passed to |
A trainControl object, potentially modified for blocked CV.
if (requireNamespace("caret", quietly = TRUE)) {
spatial_data <- data.frame(
lon = runif(50), lat = runif(50), response = rnorm(50)
)
ctrl <- borg_trainControl(
data = spatial_data,
method = "cv",
number = 5,
coords = c("lon", "lat")
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.