Sklearn One Hot Encoder icon

Sklearn One Hot Encoder

One-hot encode categorical features using scikit-learn

Fit Transform

AI-generated

Summary

Fit the encoder on the provided categorical columns and transform the data into one‑hot encoded features.

Inputs

  • columns (required) — Comma-separated list of categorical columns to encode
  • dropFirst — Whether to drop the first category to avoid multicollinearity
  • handleUnknown — How to handle unknown categories during transform
  • pythonPath — Path to Python executable with scikit-learn installed

Output shape

an array of records extending each input item with new columns for each encoded category

the number of new columns equals the number of categories minus one when dropFirst is true; additional encoder metadata (encoder, encoded_columns, categories) may be added; fields are optional and may be missing if no encoding is applied

Examples

Example 1: Encode categorical columns color and size

Columns: color,size; Drop First: false; Handle Unknown: error; Python Path: python3

Example 2: Transform new data using a fitted encoder

Encoder Data: ; Transform Columns: color,size; Handle Unknown: ignore

Example 3: Fit and transform while dropping the first category

Columns: category; Drop First: true; Handle Unknown: error

Discussion