Sklearn Label Encoder icon

Sklearn Label Encoder

Encode categorical labels as integers using scikit-learn

Fit Transform

AI-generated

Summary

Fit a LabelEncoder on a categorical column and add encoded integers as a new column.

Inputs

  • column (required) — Column containing categorical labels to encode
  • outputColumn — Name for the output column. Leave empty to use original column name with suffix.
  • pythonPath — Path to Python executable with scikit-learn installed

Output shape

a list of items with an added encoded column; first item also includes fitted encoder classes and label mapping

The transformed values are stored in the column specified by outputColumn (or original column name with suffix). The first returned item contains the encoder's classes and label mapping for later use.

Examples

Example 1: Encode product categories and store result in a new column

operation=fitTransform, column=product_category, outputColumn=product_category_encoded

Example 2: Encode a text field using the default suffix for the output column

operation=fitTransform, column=region

Example 3: Fit encoder on a column and later transform using the fitted encoder

Step 1: operation=fitTransform, column=city; Step 2: operation=transform, encoderData=<result of step 1>, transformColumn=city

Discussion