xai4tsc.data.data_loaders
File-format loaders (FORMAT_LOADERS) and JSON / metadata I/O helpers.
Attributes
Functions
|
Load a labels JSON file. |
|
Load a standalone metadata JSON file into a one-row-per-sample DataFrame. |
Module Contents
- xai4tsc.data.data_loaders.logger
- xai4tsc.data.data_loaders.FORMAT_LOADERS
- xai4tsc.data.data_loaders.load_json(path: pathlib.Path) tuple
Load a labels JSON file.
The file must contain a list of records. A
"label"key is required; all other keys are treated as metadata columns.- Parameters:
path (Path) – Path to the
.jsonfile.- Returns:
(labels, metadata)— metadata isNonewhen no extra columns exist.- Return type:
tuple[pd.Series, pd.DataFrame | None]
- Raises:
ValueError – If no
"label"key is found.
- xai4tsc.data.data_loaders.load_metadata(path: pathlib.Path) pandas.DataFrame | None
Load a standalone metadata JSON file into a one-row-per-sample DataFrame.
Accepts two shapes:
a records list
[{...}, {...}, ...]— the framework’s ownorient="records"output, andan index-keyed dict
{"0": {...}, "1": {...}, ...}— sorted by integer key into sample order.
Nested values (lists / dicts, e.g. per-class ground-truth regions) are kept as-is in object columns.
- Parameters:
path (Path) – Path to the metadata
.jsonfile.- Returns:
One row per sample, or
Noneif the file is empty.- Return type:
pd.DataFrame | None