superstats.simulation.augmentation.random_missing#
Wrapper for missing at random data augmentation process
Classes
|
MCAR missingness with a per-dataset missing probability. |
- class superstats.simulation.augmentation.random_missing.RandomMissingProcess(p_missing=None, missing_value=-1, shared_across_batch=False)[source]#
Bases:
MissingProcessMCAR missingness with a per-dataset missing probability.
Missingness is drawn per (batch, step): whenever a time step is selected as missing, all data dimensions at that step are set to missing_value (an entire observation is dropped, not individual features within it).
- Parameters:
- p_missing
float,Prior,orNone, default:None Probability that a time step is missing. - None (default): drawn from DEFAULT_P_MISSING_PRIOR, a Beta(2, 18) prior with mean 0.1. - float: fixed probability, shared across the whole batch. - Prior: sampled to obtain the probability. Sampled once for the whole batch if shared_across_batch=True, or once per dataset (default) otherwise. Prior draws (including the default) are clipped to [0, 1].
- missing_value
floatornp.ndarray, default: -1 Value written into masked entries. A scalar fills every observed variable; a mapping sets a per-variable sentinel; an array of shape
(num_variables,)sets sentinels in data-key order. Output dtype is promoted as needed (e.g.np.nanforces float;-1stays int on int data).- shared_across_batchbool, default:
False If True, one probability and one mask are drawn and applied to every dataset in the batch. If False (default), each dataset gets its own probability draw and its own mask.
- p_missing
- Parameters:
- apply(data, rng=None)[source]#
Apply the missingness process.
- Parameters:
- data
mappingofnp.ndarray Simulated data to corrupt with missingness.
- rng
np.random.GeneratororNone,optional, default:None Random generator to use. If None, a fresh, unseeded generator is created via _default_rng, so calling apply directly is safe but not reproducible unless a seeded rng is supplied.
- data
- Returns:
- result
flatdictwithdatakeys, “missing_mask”,andoptionalmetadata
- result
- Parameters:
- Return type: