snorkel.preprocess.LambdaPreprocessor

class snorkel.preprocess.LambdaPreprocessor(name, f, pre=None, memoize=False, memoize_key=None)[source]

Bases: snorkel.map.core.LambdaMapper

Convenience class for defining preprocessors from functions.

See snorkel.map.core.LambdaMapper for details.

__init__(name, f, pre=None, memoize=False, memoize_key=None)[source]

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

Return type

None

Methods

__init__(name, f[, pre, memoize, memoize_key])

Initialize self.

reset_cache()

Reset the memoization cache.

__call__(x)[source]

Run mapping function on input data point.

Deep copies the data point first so as not to make accidental in-place changes. If memoize is set to True, an internal cache is checked for results. If no cached results are found, the computed results are added to the cache.

Parameters

x (Any) – Data point to run mapping function on

Returns

Mapped data point of same format but possibly different fields

Return type

DataPoint

reset_cache()[source]

Reset the memoization cache.

Return type

None