snorkel.augmentation.ApplyEachPolicy

class snorkel.augmentation.ApplyEachPolicy(n_tfs, keep_original=True)[source]

Bases: snorkel.augmentation.policy.core.Policy

Apply each TF individually to each data point.

This can be used as a baseline policy when using complex transformations which might degenerate if combined.

Parameters
  • n_tfs (int) – Total number of TFs

  • keep_original (bool) – Keep untransformed data point in augmented data set? Note that even if in-place modifications are made to the original data point by the TFs being applied, the original data point will remain unchanged.

Example

>>> policy = ApplyEachPolicy(3, keep_original=True)
>>> policy.generate_for_example()
[[], [0], [1], [2]]
n[source]

Total number of TFs

n_per_original[source]

Total number of TFs

keep_original[source]

See above

__init__(n_tfs, keep_original=True)[source]

Initialize self. See help(type(self)) for accurate signature.

Return type

None

Methods

__init__(n_tfs[, keep_original])

Initialize self.

generate()

Generate a sequence of TF indices.

generate_for_example()

Generate all length-one sequences for a single example.

generate()[source]

Generate a sequence of TF indices.

Returns

Indices of TFs to run on data point in order.

Return type

List[int]

Raises

NotImplementedError – Subclasses need to implement this method

generate_for_example()[source]

Generate all length-one sequences for a single example.

Returns

Sequences of indices of TFs to run on data point in order.

Return type

List[List[int]]