snorkel.slicing.slicing_function¶
-
class
snorkel.slicing.
slicing_function
(name=None, resources=None, pre=None)[source]¶ Bases:
object
Decorator to define a SlicingFunction object from a function.
- Parameters
name (
Optional
[str
]) – Name of the SFresources (
Optional
[Mapping
[str
,Any
]]) – Slicing resources passed in tof
viakwargs
preprocessors – Preprocessors to run on data points before SF execution
Examples
>>> @slicing_function() ... def f(x): ... return x.a > 42 >>> f SlicingFunction f, Preprocessors: [] >>> from types import SimpleNamespace >>> x = SimpleNamespace(a=90, b=12) >>> f(x) True
>>> @slicing_function(name="my_sf") ... def g(x): ... return 0 if x.a > 42 else -1 >>> g SlicingFunction my_sf, Preprocessors: []
-
__init__
(name=None, resources=None, pre=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
- Return type
None
Methods
__init__
([name, resources, pre])Initialize self.