matten-mlprep 0.20.1

Small, transparent, deterministic preprocessing helpers for matten::Tensor (no ML framework).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
//! Deterministic ordered train/test split.
//! Run: cargo run -p matten-mlprep --example mlprep_train_test_split
use matten::Tensor;
use matten_mlprep::train_test_split;

fn main() {
    // 5 samples, 2 features.
    let x = Tensor::new((0..10).map(|v| v as f64).collect(), &[5, 2]);
    let (train, test) = train_test_split(&x, 0.6).expect("valid split"); // 3 / 2
    println!("train {:?}: {:?}", train.shape(), train.as_slice());
    println!("test  {:?}: {:?}", test.shape(), test.as_slice());
}