caikit.core.augmentors

Augmentors apply different types of data augmentation to data model objects, or data streams of data model objects.

Submodules

Classes

AugmentorBase

MergedAugmentor

AlwaysSelectionScheme

SchemeBase

RandomMultiSelectionScheme

RandomSingleSelectionScheme

Package Contents

class caikit.core.augmentors.AugmentorBase(random_seed, produces_none=False)[source]
produces_none = False
augment(inp_obj)[source]

Take an object in, give an object back. Calls ._augment in the subclass.

Args:
inp_obj (str | caikit.core.data_model.DataBase): Object to be

augmented.

Returns:
str | caikit.core.data_model.DataBase: Augmented object of same type

as input inp_obj.

reset()[source]

Reset random number generation for the current augmentor. Note that this currently assumes the augmentor is using the builtin random generator leveraged by Python; if you end up using something else, you may want to override this or restructure this base class to allow resetting of random states based on seed type.

class caikit.core.augmentors.MergedAugmentor(scheme)[source]

Bases: caikit.core.augmentors.base.AugmentorBase

_scheme
augmentor_type
_augment(obj)[source]

Apply a merged augmentor whose behavior is controlled by the encapsulated scheme.

Args:

obj (str | caikit.core.data_model.DataBase): Object to be augmented.

Returns:
str | caikit.core.data_model.DataBase: Augmented object of same type

as input obj.

reset()[source]

Reset the merge augmentor’s random number generation. In this case we actually don’t need to care about the augmentor random state; what matters for this is the augmentor. scheme.

class caikit.core.augmentors.AlwaysSelectionScheme(preserve_order, augmentors, random_seed=1001)[source]

Bases: caikit.core.augmentors.schemes.base.SchemeBase

_execute(obj)[source]

Execute the merged scheme by always applying every contained augmentor (in a potentially shuffled ordering, based on the value of self.preserve_order).

Args:

obj (str | caikit.core.data_model.DataBase): Object to be augmented.

Returns:
str | caikit.core.data_model.DataBase: Augmented object of same type

as input obj.

class caikit.core.augmentors.SchemeBase(preserve_order, augmentors, random_seed)[source]
_preserve_order
_current_order
_augmentors
_init_state
execute(obj)[source]

Execute the merged scheme, i.e., augment the object by leveraging the encapsulated augmentors.

Args:

obj (str | caikit.core.data_model.DataBase): Object to be augmented.

Returns:
str | caikit.core.data_model.DataBase: Augmented object of same type

as input obj.

reset()[source]

Reset the random state of all encapsulated augmentors and the scheme itself.

class caikit.core.augmentors.RandomMultiSelectionScheme(preserve_order, selection_probs, augmentors, random_seed=1001)[source]

Bases: caikit.core.augmentors.schemes.base.SchemeBase

_selection_probs
_execute(obj)[source]

Execute the merged scheme by sequentially applying augmentors (in a potentially shuffled ordering, based on the value of self.preserve_order).

Args:

obj (str | caikit.core.data_model.DataBase): Object to be augmented.

Returns:
str | caikit.core.data_model.DataBase: Augmented object of same type

as input obj.

class caikit.core.augmentors.RandomSingleSelectionScheme(selection_probs, augmentors, random_seed=1001)[source]

Bases: caikit.core.augmentors.schemes.base.SchemeBase

_selection_probs
_execute(obj)[source]

Execute the merged scheme by picking one random augmentor and applying it.

Args:

obj (str | caikit.core.data_model.DataBase): Object to be augmented.

Returns:
str | caikit.core.data_model.DataBase: Augmented object of same type

as input obj.