superstats.simulation.augmentation.random_missing#

Wrapper for missing at random data augmentation process

Classes

RandomMissingProcess([p_missing, ...])

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: MissingProcess

MCAR 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_missingfloat, Prior, or None, 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_valuefloat or np.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.nan forces float; -1 stays 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.

Parameters:
apply(data, rng=None)[source]#

Apply the missingness process.

Parameters:
datamapping of np.ndarray

Simulated data to corrupt with missingness.

rngnp.random.Generator or None, 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.

Returns:
resultflat dict with data keys, “missing_mask”, and optional metadata
Parameters:
Return type:

dict