peal.data.dataset_utils.parse_json¶
- peal.data.dataset_utils.parse_json(data_dir, config, mode, set_negative_to_zero=True)[source]¶
Parse a json label file of a confounder-controlled dataset.
The json maps sample ids to records with
values(feature list),targetandhas_confounder. Each record becomes a tensor[*values, target].- Parameters:
data_dir (
str) – Path of the json file.config (
DataConfig) – Needsconfounding_factors(length 2) and eitherconfounder_probabilityorfull_confounder_config, plusnum_samplesandsplit.mode (
str) –"train","val","test"or anything else for all keys.set_negative_to_zero (
bool, optional) – Clamp negative feature values to zero.
- Returns:
(data, keys_out)fromprocess_confounder_data_controlled, wheredatamaps string keys (the record index) to tensors. ReturnsNonewhen the config does not describe a controlled confounder setup (no other branch is implemented).- Return type: