pub struct Sample { /* private fields */ }Expand description
A transform that randomly samples rows from a RecordBatch.
Useful for creating train/test splits or reducing dataset size.
Requires the shuffle feature.
§Example
ⓘ
use alimentar::Sample;
// Sample 100 rows with a fixed seed
let sample = Sample::new(100).with_seed(42);
// Sample 10% of rows
let sample = Sample::fraction(0.1);Implementations§
Source§impl Sample
impl Sample
Sourcepub fn new(count: usize) -> Self
pub fn new(count: usize) -> Self
Creates a Sample transform that selects exactly count rows.
If the batch has fewer rows than count, all rows are returned.
Sourcepub fn fraction(frac: f64) -> Self
pub fn fraction(frac: f64) -> Self
Creates a Sample transform that selects a fraction of rows.
The fraction should be between 0.0 and 1.0.
Sourcepub fn sample_fraction(&self) -> Option<f64>
pub fn sample_fraction(&self) -> Option<f64>
Returns the sample fraction if set.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sample
impl RefUnwindSafe for Sample
impl Send for Sample
impl Sync for Sample
impl Unpin for Sample
impl UnsafeUnpin for Sample
impl UnwindSafe for Sample
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreCreates a shared type from an unshared type.