Annotations

One of the core operations in Snorkel is _annotating_ the candidates in various ways. We can think of generating features for the candidates as annotating them (creating a Feature object), and can also view supervision via labeling functions as annotating them (creating a Label object).

Core Data Models

class snorkel.models.annotation.AnnotationKey(**kwargs)[source]

The Annotation key table is a mapping from unique string names to integer id numbers. These strings uniquely identify who or what produced an annotation.

class snorkel.models.annotation.AnnotationKeySet(**kwargs)[source]

A many-to-many set of AnnotationKeys.

class snorkel.models.annotation.AnnotationMixin[source]

Mixin class for defining annotation tables.

An annotation is a value associated with a Candidate. Examples include labels, features, and predictions.

New types of annotations can be defined by creating an annotation class and corresponding annotation, for example:

from snorkel.models.annotation import AnnotationMixin
from snorkel.models.meta import SnorkelBase

class NewAnnotation(AnnotationMixin, SnorkelBase):
    value = Column(Float, nullable=False)


# The entire storage schema, including NewAnnotation, can now be initialized with the following import
import snorkel.models

The annotation class should include a Column attribute named value.

class snorkel.models.annotation.Feature(**kwargs)[source]

An element of a representation of a Candidate in a feature space.

A Feature’s annotation key identifies the definition of the Feature, e.g., a function that implements it or the library name and feature name in an automatic featurization library.

class snorkel.models.annotation.Label(**kwargs)[source]

A discrete label associated with a Candidate, indicating a target prediction value.

Labels are used to represent both human-provided annotations and the output of labeling functions.

A Label’s annotation key identifies the person or labeling function that provided the Label.

class snorkel.models.annotation.Prediction(**kwargs)[source]

A probability associated with a Candidate, indicating the degree of belief that the Candidate is true.

A Prediction’s annotation key indicates which process or method produced the Prediction, e.g., which model with which ParameterSet.

Core Objects for Annotations (Features, Labels)