pub struct ShuffleSplit { /* private fields */ }Expand description
Random-permutation cross-validation.
Yields n_splits independent train/test splits, each formed by permuting the
samples and slicing off a test set and a training set. Unlike
KFold, the splits are not guaranteed to partition the
dataset — the same sample may be tested in several splits or none, and (if
train_size + test_size < n) some samples may be left out of a given split
entirely.
use model_selection_rs::splitters::{CvSplitter, ShuffleSplit, SubsetSize};
let ss = ShuffleSplit::new(5)
.with_test_size(SubsetSize::Fraction(0.25))
.with_seed(0);
let splits = ss.split(40).unwrap();
assert_eq!(splits.len(), 5);
assert_eq!(splits[0].1.len(), 10); // 25% of 40Implementations§
Source§impl ShuffleSplit
impl ShuffleSplit
Sourcepub fn new(n_splits: usize) -> Self
pub fn new(n_splits: usize) -> Self
Create a ShuffleSplit with n_splits splits, a default test size of
10%, and the remainder used for training.
Sourcepub fn with_test_size(self, test_size: SubsetSize) -> Self
pub fn with_test_size(self, test_size: SubsetSize) -> Self
Set the test-subset size.
Sourcepub fn with_train_size(self, train_size: SubsetSize) -> Self
pub fn with_train_size(self, train_size: SubsetSize) -> Self
Set the train-subset size (defaults to “everything not in test”).
Trait Implementations§
Source§impl Clone for ShuffleSplit
impl Clone for ShuffleSplit
Source§fn clone(&self) -> ShuffleSplit
fn clone(&self) -> ShuffleSplit
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl CvSplitter for ShuffleSplit
impl CvSplitter for ShuffleSplit
Auto Trait Implementations§
impl Freeze for ShuffleSplit
impl RefUnwindSafe for ShuffleSplit
impl Send for ShuffleSplit
impl Sync for ShuffleSplit
impl Unpin for ShuffleSplit
impl UnsafeUnpin for ShuffleSplit
impl UnwindSafe for ShuffleSplit
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