xpectra.data

Data loading for the trust study, built on xpectra.pipeline.

Functions

leave_one_class_out(y, held_class)

Masks for synthetic OOD: train without one class, hold it out as OOD.

load_external(study_id, feature_columns, ...)

One external augmentation pool (openspecy / simple / awi2024) from the norm route.

load_labeled(route, trust[, pre])

Labeled spectra (4 studies, unknowns dropped), grouped 6-class labels.

load_unknown(route, feature_columns, ...[, pre])

The kedzierski_2019_u unlabeled environmental pool, on the labeled grid.

loso_splits(study)

Leave-one-study-out folds over the labeled studies.

xpectra.data.load_labeled(route, trust, pre=None)[source]

Labeled spectra (4 studies, unknowns dropped), grouped 6-class labels.

When trust.dedupe_spectra is set, exact-duplicate spectra within a study are dropped (keep-first) before the arrays are returned; n_dropped_duplicates records how many rows were removed.

Parameters:
Return type:

dict[str, Any]

xpectra.data.load_unknown(route, feature_columns, wavenumbers, trust, pre=None)[source]

The kedzierski_2019_u unlabeled environmental pool, on the labeled grid.

Parameters:
Return type:

dict[str, Any]

xpectra.data.load_external(study_id, feature_columns, label_encoder, trust, pre=None)[source]

One external augmentation pool (openspecy / simple / awi2024) from the norm route.

The combined route files carry all datasets; externals are selected by their study id and are never part of load_labeled. Returns (X, y, source) on the labeled feature grid, with labels already in the 6-group scheme encoded by label_encoder. source is the per-row source_study (finer than the dataset id only for openspecy), joined from the catalog DB; it falls back to the dataset id if the catalog is absent.

Parameters:
Return type:

tuple[ndarray, ndarray, ndarray]

xpectra.data.loso_splits(study)[source]

Leave-one-study-out folds over the labeled studies.

Parameters:

study (ndarray)

Return type:

Iterator[tuple[str, ndarray, ndarray]]

xpectra.data.leave_one_class_out(y, held_class)[source]

Masks for synthetic OOD: train without one class, hold it out as OOD.

Parameters:
Return type:

tuple[ndarray, ndarray]