
Cross-validate psvr_mape() with automatic warm-start across folds
psvr_cv.RdFits a psvr_mape() model on each split in splits, carrying the converged
dual variables (alpha, alpha_star) from one fold into the next as the SMO
warm-start, so each solve starts from the previous fold's optimum instead of
from zero. Because consecutive folds share most of their training rows, that
starting point is already close to feasible; before each solve the carried
vectors are projected back onto the constraint set (the equality
\(\sum_k \beta_k = 0\) and the per-sample box), with the
residual violation absorbed by the rows that are new to this fold. The
warm-start procedure is Algorithm 1 of arXiv:2605.01446 v3. Returns a tibble
with one row per fold.
Arguments
- splits
Either an
rsample::rsetobject (e.g. fromrsample::vfold_cv()), or a list of named lists each containinganalysis(data frame),assessment(data frame), and optionallyrow_ids(integer vector of original training-row indices used for warm-start alignment across folds; defaults to positional).- ...
Arguments forwarded to
psvr_mape(). Must specifykerneland the MAPE hyperparameters (C,eps).alpha_initandalpha_star_initare managed internally; supplying them via...is an error, and so isloss, which is not an argument ofpsvr_mape().- X_var
Character vector of predictor column names.
- y_var
Single character giving the target column name.
- warm_start
Logical; if
FALSE, each fold fits cold-start (useful for benchmarking the T5 speedup).- verbose
Logical; if
TRUE, report per-fold progress viamessage()(suppressible withsuppressMessages()).
Value
A tibble with one row per split and columns:
split_id1-based fold index.
fitA list-column of
psvr_mapeobjects, orpsvr_mape_symwhensym_typeis"even"or"odd".predictionsA list-column of numeric vectors (predictions on the assessment set).
metricsA list-column of named numeric vectors (
mape,rmspe,mse,r2).iter_countInteger; SMO iterations from
fit$iterations.elapsed_secNumeric; wall-clock seconds for the fit.
warm_startedLogical;
TRUEfor fold > 1 whenwarm_start = TRUE.
Details
This helper is MAPE-only, and there is no loss argument. That is a
limitation of the implementation, not of the method: only psvr_mape() was
ever wired to it. LS-SVR cross-validates perfectly well, it simply has no
carryover state to exploit (each fold is a single linear-system solve), so
for psvr_rmspe() use tune::tune_grid() with parallel cold-start.
Examples
if (requireNamespace("rsample", quietly = TRUE) &&
requireNamespace("tibble", quietly = TRUE)) {
set.seed(2026)
d <- data.frame(
y = stats::rlnorm(80, sdlog = 1.0),
x1 = stats::rnorm(80),
x2 = stats::rnorm(80)
)
folds <- rsample::vfold_cv(d, v = 5)
res <- psvr_cv(folds, X_var = c("x1", "x2"), y_var = "y",
kernel = make_kernel("rbf", sigma = 1),
C = 10, eps = 5)
median(vapply(res$metrics, function(m) m[["mape"]], numeric(1)))
}
#> Warning: SMO solver did not converge within max_iter = 100000 (final iter = 100000)
#> [1] 157.6322