How to use the snorkel.labeling.labeling_function function in snorkel

To help you get started, we’ve selected a few snorkel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github snorkel-team / snorkel / test / labeling / apply / test_spark.py View on Github external
@labeling_function(pre=[square])
def fp(x: DataPoint) -> int:
    return 0 if x.num_squared > 42 else -1
github snorkel-team / snorkel / test / labeling / apply / test_lf_applier.py View on Github external
@labeling_function()
def f_np(x: DataPoint) -> int:
    return 0 if x[1] > 42 else -1
github snorkel-team / snorkel / test / labeling / lf / test_core.py View on Github external
        @labeling_function()
        def lf(x: DataPoint) -> int:
            return 0 if x.num > 42 else -1
github snorkel-team / snorkel / test / labeling / apply / test_lf_applier.py View on Github external
        @labeling_function(pre=[spacy])
        def has_verb(x: DataPoint) -> int:
            return 0 if sum(t.pos_ == "VERB" for t in x.doc) > 0 else -1
github snorkel-team / snorkel-tutorials / spouse / spouse_demo.py View on Github external
@labeling_function()
def lf_married(x):
    return POSITIVE if "married" in x.between_tokens else ABSTAIN
github snorkel-team / snorkel-tutorials / getting_started / getting_started.py View on Github external
@labeling_function()
def lf_regex_check_out(x):
    """Spam comments say 'check out my video', 'check it out', etc."""
    return SPAM if re.search(r"check.*out", x.text, flags=re.I) else ABSTAIN
github snorkel-team / snorkel-tutorials / spouse / spouse_demo.py View on Github external
@labeling_function(resources=dict(other=other))
def lf_other_relationship(x, other):
    return NEGATIVE if len(other.intersection(set(x.between_tokens))) > 0 else ABSTAIN
github snorkel-team / snorkel-tutorials / crowdsourcing / crowdsourcing_tutorial.py View on Github external
@labeling_function(pre=[textblob_polarity])
def polarity_positive(x):
    return 1 if x.polarity > 0.3 else -1
github snorkel-team / snorkel-tutorials / visual_relation / visual_relation_tutorial.py View on Github external
@labeling_function()
def lf_carry_subject(x):
    if x.object_category == "person":
        if x.subject_category in ["chair", "bike", "snowboard", "motorcycle", "horse"]:
            return CARRY
    return ABSTAIN
github snorkel-team / snorkel-tutorials / visual_relation / visual_relation_tutorial.py View on Github external
@labeling_function()
def lf_dist(x):
    if np.linalg.norm(np.array(x.subject_bbox) - np.array(x.object_bbox)) <= 1000:
        return OTHER
    return ABSTAIN