Skip to main content

PartsSplit

Trait PartsSplit 

Source
pub trait PartsSplit<T>: Iterator<Item = T> + Sized {
    // Required method
    fn split_parts(self, splits: &[f32]) -> PartsIterator<T, Self>;
}
Expand description

An iterator trait to generate splits from a data stream of unknown lenght.

§Example

use rand_split::PartsSplit;

let splits = [4., 7., 2.5];

let cont = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
let (mut train, mut test, mut valid) = (Vec::new(), Vec::new(), Vec::new());
cont.iter().split_parts(&splits).for_each(|sp| {
    train.push(sp[0]);
    test.push(sp[1]);
    valid.push(sp[2])
});
println!(
    "Train: {:#?}, Test: {:#?}, Validation: {:#?}",
    train, test, valid
);

Required Methods§

Source

fn split_parts(self, splits: &[f32]) -> PartsIterator<T, Self>

splits contains weights that are not required to sum up to 1.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T, I> PartsSplit<T> for I
where I: Iterator<Item = T>,