pub trait CvSplitter {
// Required methods
fn split(&self, n_samples: usize) -> Result<Vec<(Vec<usize>, Vec<usize>)>>;
fn n_splits(&self) -> usize;
}Expand description
A cross-validation splitting strategy.
Implementors return (train, test) index pairs for a dataset of
n_samples rows. The indices are into the original row order; apply them
with ndarray::ArrayBase::select.
use model_selection_rs::splitters::{CvSplitter, KFold};
let kf = KFold::new(3).unwrap();
let splits = kf.split(6).unwrap();
assert_eq!(splits.len(), 3);
for (train, test) in &splits {
assert_eq!(train.len() + test.len(), 6);
}Required Methods§
Sourcefn split(&self, n_samples: usize) -> Result<Vec<(Vec<usize>, Vec<usize>)>>
fn split(&self, n_samples: usize) -> Result<Vec<(Vec<usize>, Vec<usize>)>>
Produce every (train_indices, test_indices) pair for n_samples rows.
§Errors
Returns ModelSelectionError if the
configuration cannot produce valid splits for n_samples (for example
more folds than samples, or — for stored-label splitters — an
n_samples that disagrees with the stored label array length).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".