cursus.processing.categorical.categorical_label_processor¶
- class CategoricalLabelProcessor(initial_categories=None, update_on_new=True, unknown_label=-1)[source]¶
Bases:
ProcessorMap 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: undernum_workers > 0the 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 completeinitial_categorieslist and setupdate_on_new=Falseso the mapping is fixed and read-only during processing.