pub struct KFold { /* private fields */ }Expand description
Shuffled K-fold splitter with a fixed seed, so results are reproducible.
Implementations§
Source§impl KFold
impl KFold
pub fn new(n_folds: usize, seed: u64) -> Result<Self>
pub fn n_folds(&self) -> usize
Sourcepub fn split(&self, n: usize) -> Result<Vec<Fold>>
pub fn split(&self, n: usize) -> Result<Vec<Fold>>
Split 0..n into n_folds disjoint test sets covering every index once.
Sourcepub fn split_stratified(&self, strata: &[usize]) -> Result<Vec<Fold>>
pub fn split_stratified(&self, strata: &[usize]) -> Result<Vec<Fold>>
Stratified split: the rows of each stratum (e.g. treated / control) are shuffled and dealt round-robin over the folds, so every fold holds about the same share of each stratum. Fails if a stratum has fewer rows than there are folds.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KFold
impl RefUnwindSafe for KFold
impl Send for KFold
impl Sync for KFold
impl Unpin for KFold
impl UnsafeUnpin for KFold
impl UnwindSafe for KFold
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more