Skip to main content

cv_fdata

Function cv_fdata 

Source
pub fn cv_fdata<F, P>(
    data: &FdMatrix,
    y: &[f64],
    fit_fn: F,
    predict_fn: P,
    n_folds: usize,
    nrep: usize,
    cv_type: CvType,
    stratified: bool,
    seed: u64,
) -> CvFdataResult
where F: Fn(&FdMatrix, &[f64]) -> Box<dyn Any>, P: Fn(&dyn Any, &FdMatrix) -> Vec<f64>,
Expand description

Generic k-fold + repeated cross-validation framework (R’s cv.fdata).

The user provides fit/predict closures so this works with any model.

§Arguments

  • data — Functional data matrix (n × m)
  • y — Response vector (length n); for classification, should be 0, 1, 2, …
  • fit_fn — Closure that fits a model on training data and returns a boxed model
  • predict_fn — Closure that predicts from a model on test data
  • n_folds — Number of CV folds
  • nrep — Number of repetitions (1 = single CV, >1 = repeated)
  • cv_type — Whether this is regression or classification
  • stratified — Whether to stratify folds
  • seed — Random seed for fold assignment