dataset

dataset

Aligned datasets that bridge feature and label research with model fitting.

Classes

Name Description
Dataset One aligned collection of model inputs, targets, weights, and metadata.
DatasetView A partition-backed view over one aligned :class:Dataset.
Fold A dataset facade bound to one split within a split scheme.
Partition A named subset and its role in model fitting or evaluation.
PurgedTimeSeriesSplit Walk-forward folds purged by label horizons and optional embargo.
Split One assignment of dataset rows to named partitions.
SplitScheme A named collection of splits, such as the folds of walk-forward CV.
TemporalSplit Create one ordered train/validation/test assignment.
TimeSeriesSplit Wrap sklearn’s expanding or rolling time-series cross-validator.

Dataset

dataset.Dataset(
    X,
    y=None,
    sample_weight=None,
    metadata=None,
    *,
    on=None,
    splits=None,
)

One aligned collection of model inputs, targets, weights, and metadata.

The pandas index is the dataset’s row identity: X, y, sample_weight, and metadata must describe the same indexed rows. When on is provided, each component must expose those keys either as DataFrame columns or as its complete named index. Key columns become the canonical dataset index, and component rows are reordered to X order.

Attributes

Name Description
index Return the canonical row index shared by every dataset component.
is_split Return whether at least one split scheme is attached.
partitions Return named views from the first split of the default scheme.
test Return the default split’s conventional test partition.
train Return the default split’s conventional train partition.
validation Return the default split’s conventional validation partition.

Methods

Name Description
fold Return a dataset facade bound to one fold in scheme.
load Load a dataset written by :meth:save.
partition Return a row view for one partition in one split scheme.
save Serialize the aligned dataset and all split metadata with joblib.
split Return a dataset with the split or scheme produced by splitter.
to_pandas Return selected aligned components as one optionally bounded frame.
with_split Return a dataset sharing the same data with an added split scheme.
fold
dataset.Dataset.fold(scheme, fold=0)

Return a dataset facade bound to one fold in scheme.

load
dataset.Dataset.load(path)

Load a dataset written by :meth:save.

Only load files from trusted sources because joblib uses pickle.

partition
dataset.Dataset.partition(name, *, scheme='default', fold=0)

Return a row view for one partition in one split scheme.

save
dataset.Dataset.save(path)

Serialize the aligned dataset and all split metadata with joblib.

split
dataset.Dataset.split(splitter)

Return a dataset with the split or scheme produced by splitter.

to_pandas
dataset.Dataset.to_pandas(components=_COMPONENTS, *, start=None, end=None)

Return selected aligned components as one optionally bounded frame.

with_split
dataset.Dataset.with_split(split)

Return a dataset sharing the same data with an added split scheme.

DatasetView

dataset.DatasetView(dataset, split, partition)

A partition-backed view over one aligned :class:Dataset.

Attributes

Name Description
X Return feature rows assigned to this partition.
index Return row labels assigned to this partition.
metadata Return row metadata assigned to this partition, when present.
sample_weight Return sample weights assigned to this partition, when present.
y Return target rows assigned to this partition, when present.

Methods

Name Description
to_pandas Return selected partition components as one optionally bounded frame.
to_pandas
dataset.DatasetView.to_pandas(components=_COMPONENTS, *, start=None, end=None)

Return selected partition components as one optionally bounded frame.

Fold

dataset.Fold(dataset, scheme, split)

A dataset facade bound to one split within a split scheme.

Attributes

Name Description
X Return the complete feature frame governed by this fold.
index Return the parent dataset’s canonical row index.
is_split Return True because this facade is bound to one split.
metadata Return the complete row metadata governed by this fold.
name Return this fold’s split name.
partitions Return named partition views for this fold.
sample_weight Return the complete aligned sample weights governed by this fold.
test Return this fold’s conventional test partition.
train Return this fold’s conventional train partition.
validation Return this fold’s conventional validation partition.
y Return the complete aligned target governed by this fold.

Methods

Name Description
partition Return one named partition view from this fold.
partition
dataset.Fold.partition(name)

Return one named partition view from this fold.

Partition

dataset.Partition(name, role, metadata=dict())

A named subset and its role in model fitting or evaluation.

PurgedTimeSeriesSplit

dataset.PurgedTimeSeriesSplit(
    n_splits=5,
    max_train_size=None,
    test_size=None,
    gap=0,
    name='purged_walk_forward',
    label_end='label_end_time',
    embargo=0,
)

Walk-forward folds purged by label horizons and optional embargo.

Parameters

Name Type Description Default
label_end str Metadata column containing each row’s inclusive label end. 'label_end_time'
embargo int | str | pd.Timedelta Additional separation before each test partition, expressed as a row count or pandas-compatible timedelta string. 0

Methods

Name Description
split Return sklearn folds after removing overlapping training labels.
split
dataset.PurgedTimeSeriesSplit.split(dataset)

Return sklearn folds after removing overlapping training labels.

Split

dataset.Split(membership, partitions, name='default', metadata=dict())

One assignment of dataset rows to named partitions.

Attributes

Name Description
fit_partitions Return names of partitions from which learned state may be fitted.

Methods

Name Description
partition Return one partition definition by name.
partition
dataset.Split.partition(name)

Return one partition definition by name.

SplitScheme

dataset.SplitScheme(splits, name='default', metadata=dict())

A named collection of splits, such as the folds of walk-forward CV.

Methods

Name Description
split Return a split by zero-based fold position or name.
split
dataset.SplitScheme.split(fold=0)

Return a split by zero-based fold position or name.

TemporalSplit

dataset.TemporalSplit(
    train_end=None,
    validation_end=None,
    test_end=None,
    name='default',
    train_size=None,
    validation_size=None,
    test_size=None,
)

Create one ordered train/validation/test assignment.

Parameters

Name Type Description Default
train_end Any | None Inclusive end of the training partition. Alternatively, use the size arguments to assign partitions by row count or proportion. None
validation_end Any | None Inclusive end of validation. Omit validation by leaving this as None. None
test_end Any | None Inclusive end of test. Rows after it are excluded. By default, test extends to the end of the dataset. None
name str Split name. 'default'
train_size int | float | None Training row count or proportion. None
validation_size int | float | None Validation row count or proportion. Leaving it unset omits validation in size mode. None
test_size int | float | None Test row count or proportion. When either train_size or test_size is unset, it receives the remaining rows. None

Methods

Name Description
apply Return dataset with this split attached as the default scheme.
split Return the ordered assignment for dataset.
apply
dataset.TemporalSplit.apply(dataset)

Return dataset with this split attached as the default scheme.

split
dataset.TemporalSplit.split(dataset)

Return the ordered assignment for dataset.

TimeSeriesSplit

dataset.TimeSeriesSplit(
    n_splits=5,
    max_train_size=None,
    test_size=None,
    gap=0,
    name='walk_forward',
)

Wrap sklearn’s expanding or rolling time-series cross-validator.

max_train_size selects a rolling window; leaving it unset produces expanding training windows. gap and test_size retain sklearn’s row semantics. Rows not selected in a fold receive the excluded role.

Methods

Name Description
apply Return dataset with the generated scheme attached.
split Return sklearn-generated folds as a QRT split scheme.
apply
dataset.TimeSeriesSplit.apply(dataset)

Return dataset with the generated scheme attached.

split
dataset.TimeSeriesSplit.split(dataset)

Return sklearn-generated folds as a QRT split scheme.

Functions

Name Description
audit_splits Audit all folds for ordering and label-horizon leakage.
split_diagnostics Summarize partition roles, sizes, proportions, and index boundaries.

audit_splits

dataset.audit_splits(dataset, scheme, *, label_end='label_end_time')

Audit all folds for ordering and label-horizon leakage.

A fold passes when every fit row precedes every evaluate/holdout row and, when label-end metadata exists, each fit label ends before evaluation starts.

split_diagnostics

dataset.split_diagnostics(dataset, scheme, fold=0)

Summarize partition roles, sizes, proportions, and index boundaries.

Back to top