Shrinkage

shrinkage::FoldAssignments

Shrinkage for Rust · rust · 0.3.0

pub struct FoldAssignments

Validated, zero-based held-out fold identifiers in original row order.

Every identifier from zero through nfolds - 1 must occur. At least two nonempty folds ensure that every row is held out once and trained on in every other fold. Seeded constructors use a fixed SplitMix64 shuffle.

Inherent implementation

impl FoldAssignments

assignments

pub fn assignments(&self) -> &[usize]

Held-out fold for each observation in original row order.

fold_sizes

pub fn fold_sizes(&self) -> &[usize]

Validation observation counts in fold order.

kfold

pub fn kfold(nobs: usize, nfolds: usize, seed: u64) -> Result<Self, FitError>

Shuffle observations into folds whose sizes differ by at most one.

The same arguments produce the same assignments across platforms.

Errors

Require 2 <= nfolds <= nobs.

new

pub fn new(assignments: Vec<usize>) -> Result<Self, FitError>

Validate user-supplied fold identifiers without reordering rows.

Errors

Reject empty input, fewer than two folds, gaps, or out-of-range labels.

nfolds

pub fn nfolds(&self) -> usize

Number of nonempty validation folds.

stratified_binomial

pub fn stratified_binomial(
    response: &[f64],
    nfolds: usize,
    seed: u64
) -> Result<Self, FitError>

Shuffle binary responses separately, balancing each class across folds.

Total fold sizes also differ by at most one. Fractional responses need user-supplied or ordinary shuffled folds. A rare class may still leave a training fold with a boundary response; fitting validates that separately.

Errors

Require binary responses and 2 <= nfolds <= response.len().

Implementation of Clone

impl Clone for FoldAssignments

clone

fn clone(&self) -> Self

Implementation of Debug

impl Debug for FoldAssignments

fmt

fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

Implementation of Eq

impl Eq for FoldAssignments

Implementation of PartialEq

impl PartialEq for FoldAssignments

eq

fn eq(&self, other: &Self) -> bool

Implementation of StructuralPartialEq

impl StructuralPartialEq for FoldAssignments

Implementation of Freeze

impl Freeze for FoldAssignments

Implementation of RefUnwindSafe

impl RefUnwindSafe for FoldAssignments

Implementation of Send

impl Send for FoldAssignments

Implementation of Sync

impl Sync for FoldAssignments

Implementation of Unpin

impl Unpin for FoldAssignments

Implementation of UnsafeUnpin

impl UnsafeUnpin for FoldAssignments

Implementation of UnwindSafe

impl UnwindSafe for FoldAssignments

Implementation of Any

impl<T> Any for T where T: 'static + ?Sized

Implementation of Borrow

impl<T> Borrow<T> for T where T: ?Sized

Implementation of BorrowMut

impl<T> BorrowMut<T> for T where T: ?Sized

Implementation of ByRef

impl<T> ByRef<T> for T

Implementation of CastableFrom

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT where ST: ?Sized, DT: ?Sized

Implementation of CastableFrom

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT where ST: ?Sized, DT: ?Sized

Implementation of CloneToUninit

impl<T> CloneToUninit for T where T: Clone

Implementation of Equivalent

impl<Q, K> Equivalent<K> for Q where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized

Implementation of Equivalent

impl<Q, K> Equivalent<K> for Q where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized

Implementation of From

impl<T> From<T> for T

Implementation of Imply

impl<T, U> Imply<T> for U where T: ?Sized, U: ?Sized

Implementation of Into

impl<T, U> Into<U> for T where U: From<T>

Implementation of IntoEither

impl<T> IntoEither for T

Implementation of Pointable

impl<T> Pointable for T

Implementation of Read

impl<T> Read<Exclusive, BecauseExclusive> for T where T: ?Sized

Implementation of Same

impl<T> Same for T

Implementation of Scalar

impl<T> Scalar for T where T: 'static + Clone + PartialEq + Debug

Implementation of SupersetOf

impl<SS, SP> SupersetOf<SS> for SP where SS: SubsetOf<SP>

Implementation of ToOwned

impl<T> ToOwned for T where T: Clone

Implementation of TryFrom

impl<T, U> TryFrom<U> for T where U: Into<T>

Implementation of TryInto

impl<T, U> TryInto<U> for T where U: TryFrom<T>