Fits a model on each fold's training set and evaluates on its test set, returning per-fold metrics with spatial centroids for geographic performance mapping.
Arguments
- data
Data frame with predictor and target columns.
- folds
A
borg_cvobject, or a list of fold lists (each with$trainand$testindex vectors).- formula
A model formula (e.g.
y ~ x1 + x2).- coords
Character vector of length 2. Coordinate column names for computing fold centroids. Optional.
- metric
Character. Performance metric:
"rmse"(default),"mae", or"rsq".- fit_fun
Function to fit a model. Default:
lm. Must acceptformulaanddataarguments and return an object with apredict()method.- parallel
Logical. If
TRUEand the future.apply package is installed, fold evaluation runs in parallel. Default:FALSE.