cursus.processing.categorical.categorical_label_processor

class CategoricalLabelProcessor(initial_categories=None, update_on_new=True, unknown_label=-1)[source]

Bases: Processor

Map category strings to integer labels.

Warning

With update_on_new=True (the default), process() MUTATES the category->label mapping on first sight of a new category. This is not safe across DataLoader workers: under num_workers > 0 the processor is forked per worker, so each worker assigns its own (divergent) ids to the same category and labels become inconsistent. For multi-worker / distributed use, pass a complete initial_categories list and set update_on_new=False so the mapping is fixed and read-only during processing.

process(input_text)[source]