skada.model_selection.LeaveOneDomainOut

class skada.model_selection.LeaveOneDomainOut(max_n_splits=10, *, test_size=None, train_size=None, random_state=None)[source]

Leave-One-Domain-Out cross-validator.

Provides train/test indices to split data in train/test sets.

get_n_splits(X=None, y=None, sample_domain=None)[source]

Returns the number of splitting iterations in the cross-validator

Parameters:
Xobject

Always ignored, exists for compatibility.

yobject

Always ignored, exists for compatibility.

sample_domainnp.ndarray

Per-sample domain labels.

Returns:
n_splitsint

Returns the number of splitting iterations in the cross-validator.

set_split_request(*, sample_domain: bool | None | str = '$UNCHANGED$') LeaveOneDomainOut

Request metadata passed to the split method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to split if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to split.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
sample_domainstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_domain parameter in split.

Returns:
selfobject

The updated object.

split(X, y=None, sample_domain=None)[source]

Generate indices to split data into training and test set.

Parameters:
Xarray-like of shape (n_samples, n_features)

Training data, where n_samples is the number of samples and n_features is the number of features.

yarray-like of shape (n_samples,)

The target variable for supervised learning problems.

sample_domainarray-like of shape (n_samples,), default=None

Domain labels for the samples used while splitting the dataset into train/test set.

Yields:
trainndarray

The training set indices for that split.

testndarray

The testing set indices for that split.

Notes

Randomized CV splitters may return different results for each call of split. You can make the results identical by setting random_state to an integer.

Examples using skada.model_selection.LeaveOneDomainOut

Visualizing cross-validation behavior in skada

Visualizing cross-validation behavior in skada