mlprep_train_test_split/train_test_split.rs
1//! Deterministic ordered train/test split.
2//! Run: cargo run -p matten-mlprep --example mlprep_train_test_split
3use matten::Tensor;
4use matten_mlprep::train_test_split;
5
6fn main() {
7 // 5 samples, 2 features.
8 let x = Tensor::new((0..10).map(|v| v as f64).collect(), &[5, 2]);
9 let (train, test) = train_test_split(&x, 0.6).expect("valid split"); // 3 / 2
10 println!("train {:?}: {:?}", train.shape(), train.as_slice());
11 println!("test {:?}: {:?}", test.shape(), test.as_slice());
12}