Config¶
ecgbench.config — the typed representation of a dataset's YAML file. Every
other module takes a DatasetConfig, never a raw dict.
config
¶
Dataset configuration system.
Every dataset is fully described by a YAML config file. This module provides the typed DatasetConfig dataclass and a loader that parses YAML into it.
CreatorInfo
dataclass
¶
Dataset creator or contributing organisation.
StratificationConfig
dataclass
¶
StratificationConfig(method: str, mapping_source: str | None = None, superclass_column: str | None = None)
How to derive stratification labels for splitting.
ValidationConfig
dataclass
¶
ValidationConfig(expected_leads: int, expected_samples: dict[int, int], checks: list[str], amplitude_range_mv: tuple[float, float] = (-10.0, 10.0))
Quality validation settings for a dataset.
PredefinedSplitConfig
dataclass
¶
Describes a dataset's built-in fold assignments.
LabelFieldConfig
dataclass
¶
LabelFieldConfig(type: str = 'string', description: str = '', unit: str | None = None, vocabulary: list[str] | None = None, nullable: bool = True, example: str | None = None)
Type and meaning of one declarative label column (labels.fields.<name>).
The YAML counterpart of ecgbench.labels._fields.Field for datasets whose
labels are a plain column select: type is a Frictionless Table Schema
type (string, integer, number, boolean, array[string] …),
vocabulary the closed set of values as strings, nullable whether a
record may lack a value.
LabelConfig
dataclass
¶
LabelConfig(available: bool = True, source_csv: str | None = None, separator: str = ',', join_column: str | None = None, columns: list[str] | None = None, fields: dict[str, LabelFieldConfig] | None = None, unavailable_reason: str = '')
Where a dataset's per-record labels and metadata come from.
Exported fold CSVs are identification-only, so ground truth always lives in
the source dataset. This block says which file holds it and how to join it
back to the fold CSVs. Datasets needing a derivation beyond a column select
(PTB-XL's SCP-to-superclass reduction, say) get a module in
ecgbench/labels/ instead; the fields here still describe the source file
so a missing-file error can name it.
CroissantConfig
dataclass
¶
CroissantConfig(keywords: list[str] = list(), rai_data_collection: str = '', rai_data_biases: str = '', rai_personal_sensitive_info: str = '')
Croissant (MLCommons) metadata fields.
DatasetConfig
dataclass
¶
DatasetConfig(name: str, slug: str, version: str, url: str, download_url: str | None = None, license: str = '', description: str = '', citation: str = '', doi: str = '', creators: list[CreatorInfo] = list(), signal_format: str = 'wfdb', signal_unit_scale: float = 1.0, signal_units: str = 'mV', leads: int = 12, lead_names: list[str] | None = None, alternate_lead_names: dict[int, list[str]] | None = None, record_lead_layouts: list[list[str]] | None = None, duration_seconds: float = 10.0, sampling_rates: list[int] = (lambda: [500])(), default_sampling_rate: int = 500, metadata_csv: str = '', metadata_csv_separator: str = ',', record_id_column: str = 'ecg_id', patient_id_column: str | None = None, signal_path_columns: dict[int, str] = dict(), zero_padded_identifiers: bool = False, label_column: str = '', label_format: str = 'single', stratification: StratificationConfig | None = None, has_predefined_splits: bool = False, predefined_splits: PredefinedSplitConfig | None = None, n_folds: int = 10, validation: ValidationConfig | None = None, labels: LabelConfig | None = None, publish_fold_csvs: bool = True, no_publish_reason: str = '', croissant: CroissantConfig = CroissantConfig())
Complete typed representation of a dataset YAML config.
identifier_dtypes
¶
Columns to read as strings, for pandas.read_csv(dtype=...).
Empty unless :attr:zero_padded_identifiers is set — see there for why
this is opt-in rather than universal. Every read of a metadata or fold CSV
goes through this, so the exported CSVs, the validation engine and
ECGDataset cannot disagree about what a record is called. Unknown keys
are ignored by pandas, so the result is safe to hand to any CSV whatever
columns it actually has.
Source code in ecgbench/config.py
load_config
¶
load_config(dataset_slug: str) -> DatasetConfig
Load and validate a dataset config from YAML.
Searches ecgbench/data/configs/{dataset_slug}.yaml. Parses YAML into DatasetConfig dataclass with full validation.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
if config YAML doesn't exist |
ValueError
|
if required fields are missing or invalid |
Source code in ecgbench/config.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
list_available_configs
¶
Return slugs of all available dataset configs.