from snorkel.labeling import labeling_function
@labeling_function()
def check(x):
return SPAM if "check" in x.text.lower() else ABSTAIN
When labeling functions get decorated as snorkel.labeling.LabelingFunction, fonduer.supervision.Labeler.apply stops working.
To Reproduce
Steps to reproduce the behavior:
Decorate labeling functions as snorkel.labeling.LabelingFunction
Run Labeler.apply
Expected behavior
Decorated labeling functions work with fonduer.supervision.Labeler.apply.
Error Logs/Screenshots
Process LabelerUDF-54:
Process LabelerUDF-55:
Traceback (most recent call last):
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/utils/udf.py", line 207, in run
y = self.apply(doc, **self.apply_kwargs)
Process LabelerUDF-53:
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/utils/udf.py", line 207, in run
y = self.apply(doc, **self.apply_kwargs)
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 481, in apply
list(get_mapping(table, cands, self._f_gen)) for cands in cands_list
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 481, in apply
list(get_mapping(table, cands, self._f_gen)) for cands in cands_list
Traceback (most recent call last):
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 481, in <listcomp>
list(get_mapping(table, cands, self._f_gen)) for cands in cands_list
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 481, in <listcomp>
list(get_mapping(table, cands, self._f_gen)) for cands in cands_list
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/utils/utils_udf.py", line 219, in get_mapping
for cid, key, value in generator(cand):
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/utils/utils_udf.py", line 219, in get_mapping
for cid, key, value in generator(cand):
Process LabelerUDF-52:
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/utils/udf.py", line 207, in run
y = self.apply(doc, **self.apply_kwargs)
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 438, in _f_gen
for cid, lf_key, label in labels(c):
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 438, in _f_gen
for cid, lf_key, label in labels(c):
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 437, in <lambda>
labels = lambda c: [(c.id, lf.__name__, lf(c)) for lf in self.lfs[lf_idx]]
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 437, in <lambda>
labels = lambda c: [(c.id, lf.__name__, lf(c)) for lf in self.lfs[lf_idx]]
Traceback (most recent call last):
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 481, in apply
list(get_mapping(table, cands, self._f_gen)) for cands in cands_list
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 437, in <listcomp>
labels = lambda c: [(c.id, lf.__name__, lf(c)) for lf in self.lfs[lf_idx]]
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 437, in <listcomp>
labels = lambda c: [(c.id, lf.__name__, lf(c)) for lf in self.lfs[lf_idx]]
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 481, in <listcomp>
list(get_mapping(table, cands, self._f_gen)) for cands in cands_list
AttributeError: 'LabelingFunction' object has no attribute '__name__'
AttributeError: 'LabelingFunction' object has no attribute '__name__'
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/utils/utils_udf.py", line 219, in get_mapping
for cid, key, value in generator(cand):
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/utils/udf.py", line 207, in run
y = self.apply(doc, **self.apply_kwargs)
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 481, in apply
list(get_mapping(table, cands, self._f_gen)) for cands in cands_list
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 438, in _f_gen
for cid, lf_key, label in labels(c):
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 481, in <listcomp>
list(get_mapping(table, cands, self._f_gen)) for cands in cands_list
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 437, in <lambda>
labels = lambda c: [(c.id, lf.__name__, lf(c)) for lf in self.lfs[lf_idx]]
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/utils/utils_udf.py", line 219, in get_mapping
for cid, key, value in generator(cand):
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 437, in <listcomp>
labels = lambda c: [(c.id, lf.__name__, lf(c)) for lf in self.lfs[lf_idx]]
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 438, in _f_gen
for cid, lf_key, label in labels(c):
AttributeError: 'LabelingFunction' object has no attribute '__name__'
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 437, in <lambda>
labels = lambda c: [(c.id, lf.__name__, lf(c)) for lf in self.lfs[lf_idx]]
File "/Users/hiromu/workspace/fonduer-tutorials/.venv/lib/python3.7/site-packages/fonduer/supervision/labeler.py", line 437, in <listcomp>
labels = lambda c: [(c.id, lf.__name__, lf(c)) for lf in self.lfs[lf_idx]]
AttributeError: 'LabelingFunction' object has no attribute '__name__'
Environment (please complete the following information):
Fonduer Version: 0.8.1
Additional context
I'm updating Fonduer tutorials for v0.8.1.
Describe the bug
Say I have a set of labeling functions like below:
I wanted to use
snorkel.labeling.LFAnalysis
as described in https://www.snorkel.org/use-cases/01-spam-tutorial#c-evaluate-performance-on-training-set. To do this, I had to decorate labeling functions as below:When labeling functions get decorated as
snorkel.labeling.LabelingFunction
,fonduer.supervision.Labeler.apply
stops working.To Reproduce Steps to reproduce the behavior:
snorkel.labeling.LabelingFunction
Labeler.apply
Expected behavior
Decorated labeling functions work with
fonduer.supervision.Labeler.apply
.Error Logs/Screenshots
Environment (please complete the following information):
Additional context I'm updating Fonduer tutorials for v0.8.1.