instancelib.labels.base module

class instancelib.labels.base.LabelProvider(*args, **kwds)[source]

Bases: Mapping[KT, FrozenSet[LT]], ABC, Generic[KT, LT]

document_count(label)[source]
Parameters:

label (TypeVar(LT)) –

Return type:

int

abstract get_instances_by_label(label)[source]

Retrieve which instances are annotated with label

Parameters:

label (LT) – A Label

Returns:

The identifiers of the instance

Return type:

Set[Instance]

abstract get_labels(instance)[source]

Return the labels that are associated with the instance

Parameters:

instance (Union[KT, Instance]) – The instance

Returns:

The labels that are associated with the instance

Return type:

Set[LT]

abstract property labelset: FrozenSet[LT]

for setting up a classifier)

Returns:

Labels of type LT

Return type:

Set[LT]

Type:

Report all possible labels (example usage

property len_positive: int
abstract remove_labels(instance, *labels)[source]

Remove the labels from this instance

Parameters:
  • instance (Union[KT, Instance]) – The instance

  • *labels (LT) – The labels that should be removed from the instance

Return type:

None

abstract set_labels(instance, *labels)[source]

Annotate the instance with the labels listed in the parameters

Parameters:
  • instance (Union[KT, Instance]) – The instance

  • *labels (LT) – The labels that should be associated with the instance

Return type:

None

instancelib.labels.base.columnar_label_viewer(labelset=None, prefix='', boolmapper=<function identity>)[source]
Parameters:
Return type:

Callable[[TypeVar(KT), LabelProvider[TypeVar(KT), TypeVar(LT)]], Mapping[str, Any]]

instancelib.labels.base.default_label_viewer(key, labelprovider)[source]
Parameters:
Return type:

Mapping[str, Any]