Skip to content

nexuml.data.dataset

nexuml.data.dataset

Base dataset contracts and metadata-backed helpers for NexuML.

NexuDataset

Bases: Dataset

Base dataset returning (x, y) TensorDict pairs.

The base class supports two common patterns used throughout NexuML:

  • metadata-backed datasets via self.meta
  • in-memory datasets via self.data

Subclasses can still override __getitem__ entirely for bespoke behavior.

split_meta

split_meta(split_ratio: list[float]) -> None

Convert 'fit' rows to train/val and 'all' rows to train/val/test.

get_split

get_split(split: str) -> Self

Return a view of this dataset filtered to a single split.

Returns:

Type Description
Self

A new :class:NexuDataset containing only the requested split.

Raises:

Type Description
ValueError

If the dataset has no metadata.

load_item

load_item(idx: int, row: Series) -> TensorDict

Load features for a single sample.

Subclasses can override this to lazily load file-backed content.

Returns:

Type Description
TensorDict

Feature tensor dictionary for the sample.

load_labels

load_labels(idx: int, row: Series) -> TensorDict | None

Load labels for a single sample.

By default labels are read from self.meta using self.label_names. Subclasses can override this for file-backed or computed targets.

Returns:

Type Description
TensorDict | None

Label tensor dictionary, or None if no labels are configured.

download

download() -> None

Override to implement dataset downloading.