annotated

class AnnotatedMixin(*, categories, background_category)

Bases: ABC

Mixin for annotated datasets.

Parameters:
  • categories (tuple[str, ...]) – The categories of the dataset.

  • background_category (str) – The background category of the dataset.

property category_counts: dict[str, int]

Counts of each category in the sampleable.

property encode: EncodingFunction

Function to encode category names to integers.

property foreground_categories: tuple[str, ...]

The categories of the dataset excluding the background category.

property observations: DataFrame

Return the observations of the sampleable.

sample_y()

Return the target labels of the entire sampleable (as category names).

Return type:

ndarray

class EncodingFunction(*args, **kwargs)

Bases: Protocol

Protocol for category encoding functions.

Parameters:
  • y (ndarray) – The input array to be encoded.

  • *args – Additional positional arguments.

  • **kwargs – Additional keyword arguments.

Returns:

The encoded array.

encode_categories(y, *, categories)

Encode categories to integers.

Parameters:
  • y (ndarray) – The input array to be encoded.

  • categories (tuple[str, ...]) – The categories to encode.

Return type:

ndarray

Returns:

The encoded array.