pnpl.tasks.libribrain.WordClassification

pnpl.tasks.libribrain.WordClassification#

class pnpl.tasks.libribrain.WordClassification(tmin=None, tmax=None, min_word_length=1, max_word_length=None, keyword_detection=None, negative_buffer=0.0, positive_buffer=0.0, _words_sorted=<factory>, _word_to_id=<factory>, _keyword_set=<factory>)[source]#

Word classification task.

Can operate in two modes: 1. Multi-class: Classify all words 2. Keyword detection: Binary classification for specific keyword(s)

Parameters:
  • tmin (float | None) – Start time relative to word onset (seconds). If None, auto-computed.

  • tmax (float | None) – End time relative to word onset (seconds). If None, auto-computed.

  • min_word_length (int) – Minimum word length to include

  • max_word_length (int | None) – Maximum word length to include (None for no limit)

  • keyword_detection (str | list | None) – Keyword(s) for binary detection mode

  • negative_buffer (float) – Extra time before word onset when auto-computing tmin

  • positive_buffer (float) – Extra time after word end when auto-computing tmax

  • _words_sorted (list)

  • _word_to_id (dict)

  • _keyword_set (set)

__init__(tmin=None, tmax=None, min_word_length=1, max_word_length=None, keyword_detection=None, negative_buffer=0.0, positive_buffer=0.0, _words_sorted=<factory>, _word_to_id=<factory>, _keyword_set=<factory>)#
Parameters:
  • tmin (float | None)

  • tmax (float | None)

  • min_word_length (int)

  • max_word_length (int | None)

  • keyword_detection (str | list | None)

  • negative_buffer (float)

  • positive_buffer (float)

  • _words_sorted (list)

  • _word_to_id (dict)

  • _keyword_set (set)

Return type:

None

Methods

__init__([tmin, tmax, min_word_length, ...])

collect_samples(dataset)

Collect word samples from all runs.

get_label(sample)

Extract label ID from sample.

Attributes

is_keyword_mode

Check if operating in keyword detection mode.

keyword_detection

label_info

Label metadata.

max_word_length

min_word_length

negative_buffer

positive_buffer

tmax

tmin