Skip to main content

train_test_split_core

Function train_test_split_core 

Source
pub fn train_test_split_core(
    x: &Array2<f64>,
    y: &Array1<f64>,
    test_size: Option<f64>,
    random_state: Option<u64>,
) -> PyResult<(Array2<f64>, Array2<f64>, Array1<f64>, Array1<f64>)>
Expand description

Core (Python-free) train/test split logic, directly unit-testable without a live Python interpreter – this crate builds with pyo3’s extension-module feature (required so the compiled cdylib can be imported from Python), which means Python::with_gil cannot be used from a standalone cargo test binary.

Defaults test_size to 0.25 (scikit-learn’s default) when None.

§Known limitations

The underlying sklears_model_selection::train_test_split always shuffles before splitting and has no train_size/stratify support (unlike scikit-learn’s version). Extending the core splitting algorithm to support those is out of scope for this fix.

pub (rather than crate-private) so that benches/core_helpers_benchmarks.rs – which compiles as a separate crate – can call it directly for the same reason; this is a minimal exposed surface for benchmarking, not part of the stable Python-facing API.