snorkelflow.lfs.LF
- class snorkelflow.lfs.LF(name, label=None, templates=None, multipolar_template=None, graph=None, is_trusted=False)
Bases:
objectClass to represent an immutable LF.
Examples
Create an LF.
>>> from snorkelflow.lfs import LF
>>> lf_a = LF(name="lf_a", label=0, templates=...)Due to the immutability, a new LF should be created if you want to change its attributes.
>>> lf_config = lf_a.to_dict()
>>> lf_config["name"] = "lf_b"
>>> lf_b = LF(**lf_config)- __init__(name, label=None, templates=None, multipolar_template=None, graph=None, is_trusted=False)
Initialize an LF object.
Parameters
Parameters
Name Type Default Info name strName of the LF. label Optional[Any]NoneLabel associated with the LF. This shouldn’t be provided for a multi-polar LF. templates Optional[List[Dict[str, Any]]]NoneTemplates for the LF. Each template is assigned with a 0-th based index that can be used in graph. multipolar_template Optional[Dict[str, Any]]NoneTemplate for the multi-polar LF. graph Union[str, int, List[Any], None]NoneProvide this argument to construct a compound LF, one that’s made of multiple templates. Optional if there is only one template. It is a list that starts with a logical operator, followed by template indexes or sub-lists. The logical operator can be "$AND","$OR", or"$NOT". The list can be nested but the depth should be 3 or less. For example, a compound LF with["$AND", 0, ["$NOT", 1]]votes if the 0th template returns True and the 1st template returns False, and its depth is 2.is_trusted Optional[bool]FalseIf True, designate the LF as trusted.
\_\_init\_\_
__init__
Methods
__init__(name[, label, templates, ...])Initialize an LF object. to_dict()Get a dictionary representation of the LF. Attributes
graphis_multipolaris_trustednamelabeltemplatesmultipolar_template- to_dict()
Get a dictionary representation of the LF.
to\_dict
to_dict
-
graph:
Union[str,int,List[Any],None] = None
- property is_multipolar: bool
-
is_trusted:
Optional[bool] = False
-
label:
Optional[Any]
-
multipolar_template:
Optional[Dict[str,Any]]
-
name:
str
-
templates:
Optional[List[Dict[str,Any]]]