ShuffleSplit
Module: strata.model_selection • Kind: struct • Traits: Movable
Source: strata/model_selection/shuffle_split.mojo
struct ShuffleSplit(Movable)from strata.model_selection import ShuffleSplitRandom permutation cross-validator.
Yields indices to split data into training and test sets. Each split is an independent random permutation of the samples, so successive test sets may overlap. Sizes are expressed as proportions of the total sample count.
Constructors
Section titled “Constructors”def __init__( out self, n_splits: Int = 10, test_size: Float64 = 0.1, train_size: Float64 = 0.0, random_state: Int = 42,)Initializes the ShuffleSplit cross-validator.
| Argument | Type | Description |
|---|---|---|
n_splits |
Int |
Number of re-shuffling and splitting iterations. |
test_size |
Float64 |
Proportion of samples held out for testing, in (0, 1). |
train_size |
Float64 |
Proportion of samples used for training, in (0, 1), or 0.0 to use the complement of test_size. |
random_state |
Int |
Base seed controlling the permutation of each split. |
Methods Overview
Section titled “Methods Overview”| Method | Description |
|---|---|
ShuffleSplit.get_n_splits() |
Returns the number of splitting iterations in the cross-validator. |
ShuffleSplit.split() |
Generates randomly permuted train and test indices for each split. |
Method Details
Section titled “Method Details”ShuffleSplit.get_n_splits()
Section titled “ShuffleSplit.get_n_splits()”def get_n_splits(self) -> IntReturns the number of splitting iterations in the cross-validator.
Returns: Int
ShuffleSplit.split()
Section titled “ShuffleSplit.split()”def split(self, n_samples: Int) -> List[Split]def split[dtype: DType](self, X: Matrix[dtype]) -> List[Split]Overload Note: This method supports multiple overloaded call signatures.
Generates randomly permuted train and test indices for each split.
| Parameter | Type | Description |
|---|---|---|
n_samples |
Int |
Total number of samples in the dataset. |
X |
Matrix[dtype] |
Feature matrix. |
Returns: List[Split] — List of Split objects containing train and validation indices.