pub fn train_test_split<Feature, Label>(
dataset: ClassificationDataSet<Feature, Label>,
test_size: f64,
) -> (ClassificationDataSet<Feature, Label>, ClassificationDataSet<Feature, Label>)Expand description
Split data and features into training and testing set. test_size must be between 0 and 1.
ยงPanics
Panics if test_size is outside range 0..=1.
Example:
use rs_ml::{train_test_split};
use rs_ml::classification::ClassificationDataSet;
use ndarray::{arr1, arr2};
let features = arr2(&[
[1., 0.],
[0., 1.],
[0., 0.],
[1., 1.]]);
let labels = vec![1, 1, 0, 0];
let dataset = ClassificationDataSet::from(
features.rows().into_iter().zip(labels));
let (train, test) = train_test_split(dataset, 0.25);