cursus.processing.categorical.multiclass_label_processor

class MultiClassLabelProcessor(label_list=None, one_hot=False, strict=False)[source]

Bases: Processor

Processes multi-class labels into a format suitable for machine learning models.

This processor handles encoding categorical labels into numerical arrays and optionally provides one-hot encoding using numpy.

Parameters:
  • label_list (Optional[List[str]]) – A list of unique label strings. If provided, the processor will learn this mapping; otherwise, it will learn the mapping from the data it processes.

  • one_hot (bool) – If True, output one-hot encoded labels.

  • strict (bool) – If True, raise error for unknown labels when label_list is provided.

process(labels)[source]

Encodes the input labels.

Parameters:

labels (Union[str, List[str]]) – A single label or a list of labels.

Returns:

Encoded labels as a numpy array.

Return type:

np.ndarray