Skip to content

Holdout

The Holdout object in ydata-sdk is a utility designed to create, store, and reproduce consistent train-test splits from a given Dataset. It ensures repeatability in experiments by managing the exact rows allocated to the holdout (test) set, based on a fixed sampling strategy and split fraction.

By storing essential information such as partition metadata and dataset divisions, the Holdout object supports reliable reloading of the same split configuration across different environments or workflow stages—enabling accurate evaluation of models and synthetic data.

from ydata.dataset.holdout import Holdout

holdout_config = Holdout(fraction=0.3)
train, holdout = holdout_config.get_split(X=dataset, metadata=metadata, strategy='random')

Notebook example can be found at YData Academy.

ydata.dataset.holdout.Holdout

Split a Dataset into train and hold-out (test) partitions.

A holdout is created once, published, and then loaded again elsewhere to guarantee that everyone evaluating a model sees the same rows.

Parameters

fraction : float, default 0.2 Fraction of the original dataset to place in the hold-out split. Must be strictly between 0 and 1.

Attributes

uuid : str Random identifier that uniquely tags this split instance.

holdout_def property

Cached row count of the hold-out split. None until get_split() has been called.

get_split(X, metadata=None, random_state=None, strategy='random')

Generate and cache a train / hold-out split of X.

Parameters

X : Dataset The full dataset to split. metadata : Metadata, optional Column-level metadata used by stratified sampling. random_state : RandomSeed, optional Seed for deterministic splits. strategy : {'random', 'stratified'}, default 'random'

Returns

train : Dataset holdout : Dataset

load(path) classmethod

Reload a Holdout instance from a pickle file.

Parameters

path : str File that was previously created with save().

Returns

Holdout

save(path)

Persist this Holdout object to disk with pickle.

Parameters

path : str Destination file name (e.g. "holdout.pkl").