Skip to main content

random_split

Function random_split 

Source
pub fn random_split(
    total_size: i64,
    train_ratio: f32,
    val_ratio: f32,
    seed: u64,
) -> Result<SplitResult>
Expand description

Randomly split indices into train, validation, and test subsets.

Matches donor FnDataset::randomSplit: clamp train to [0, 1] and validation to [0, 1 - train], truncate their FP32 counts, and assign the remainder to test. The donor header’s claim that the remainder goes to train contradicts its implementation; this port follows the implementation.

§Errors

Returns an error for a negative size, non-finite ratios, allocation failure, or failure to derive a clock seed when seed is zero.