pub struct KFold { /* private fields */ }Expand description
Plain K-fold cross-validation.
The sample indices are partitioned into k folds; each fold serves as the
test set once while the remaining k - 1 folds form the training set. With
shuffle the indices are permuted (deterministically,
from the given seed) before partitioning.
This is a from-scratch implementation, so the crate has zero required
dependency on smartcore; it is functionally equivalent to
smartcore::model_selection::KFold for anyone who would rather use that.
use model_selection_rs::splitters::{CvSplitter, KFold};
let kf = KFold::new(5).unwrap().with_shuffle(42);
let splits = kf.split(50).unwrap();
assert_eq!(splits.len(), 5);Implementations§
Source§impl KFold
impl KFold
Sourcepub fn new(n_splits: usize) -> Result<Self>
pub fn new(n_splits: usize) -> Result<Self>
Create a KFold with n_splits folds and no shuffling.
§Errors
Returns ModelSelectionError::InvalidSplitCount if n_splits < 2.
Sourcepub fn with_shuffle(self, seed: u64) -> Self
pub fn with_shuffle(self, seed: u64) -> Self
Enable shuffling of the sample order before folding, using seed.
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