RandomDrop#
- class RandomDrop(key: str, p_apply: float = 0.5, p_drop: float = 0.2, value: float = 0.0)[source]#
Bases:
objectRandomly overwrite a fraction of one key’s rows with a constant.
With probability
p_apply(and only ifkeyis present), selects a randomp_dropfraction of the rows ofdata_dict[key]and sets them tovalue– a feature-masking augmentation that keeps the point count unchanged. Registered asRandomDrop– use this string as thetypein atransform=[...]config list.- Parameters:
key (str) – the per-point key whose rows may be overwritten.
p_apply (float) – probability of applying the transform to a sample. Defaults to
0.5.p_drop (float) – fraction of rows to overwrite when applied. Defaults to
0.2.value (float) – constant written into the selected rows. Defaults to
0.0.
Note
Operates on a single named key only; it does not touch
coordor other point-aligned arrays, so the cloud geometry is preserved.Example
>>> import numpy as np >>> from pimm.datasets.transform import RandomDrop >>> np.random.seed(0) >>> data = {"energy": np.array([[1.], [2.], [3.], [4.]], dtype="f4")} >>> out = RandomDrop(key="energy", p_apply=1.0, p_drop=0.5, value=0.0)(data) >>> # NOTE: the write uses data[key][idx][:] = value, which assigns into a >>> # fancy-index COPY -- so as written the rows are left unchanged: >>> out["energy"].ravel() array([1., 2., 3., 4.], dtype=float32)