Performs stratified k-fold cross-validation by rotating which cells serve as the test set. Returns per-fold and aggregated metrics.
Arguments
- data
pigauto_data object (output of
preprocess_traits).- tree
phylo object.
- k
integer. Number of folds (default 5).
- seeds
integer vector. Seeds for replicate runs.
- epochs
integer. Training epochs per fold (default 500).
- verbose
logical. Print progress (default TRUE).
- ...
Additional arguments passed to
fit_pigauto(e.g.hidden_dim,k_eigen,use_attention).
Value
A list of class "pigauto_cv" with:
- results
Data.frame with columns: fold, rep, trait, type, metric, value.
- summary
Data.frame with mean and sd across folds/reps for each trait + metric.
- conformal_coverage
Data.frame of coverage per trait across folds (if available).
- k
Number of folds.
- n_reps
Number of replicates.
Examples
if (FALSE) { # \dontrun{
data(avonet300, tree300, package = "pigauto")
traits <- avonet300; rownames(traits) <- traits$Species_Key
traits$Species_Key <- NULL
pd <- preprocess_traits(traits, tree300)
cv <- cross_validate(pd, tree300, k = 5L, seeds = 1:3, epochs = 500L)
print(cv)
summary(cv)
} # }
