← All tools
EDTOOLKITS GUIDES

Category Encoding: Fit Once and Preserve the Mapping

By Team Edtoolkits · Data

Compare one-hot and ordinal outputs and handle unseen categories deliberately.

Use the guide alongside the working tool.

Open Categorical Data Encoder →

Explicit working sample

customer,order,date,product,amount
A,100,2026-01-01,Notebook,30
A,100,2026-01-01,Pen,10
B,101,2026-01-03,Notebook,25
A,102,2026-02-01,Pen,20
C,103,2026-02-02,Notebook,50
C,103,2026-02-02,Pen,15
B,104,2026-03-01,Pen,35

Create reusable one-hot or ordinal category mappings. Fit categories from training input only, or apply a saved mapping to another dataset. Lexical category ordering is explicit, not semantic. Unknown values can error or map to all-zero / -1. Missing values are treated as an explicit category. Outputs preserve source columns and add encoded fields; maximum 50 categories per column and 64 total columns.

A comparison to try

Fit a mapping on a small training table, save it and apply it to a second table containing a new category. Compare an error on unknown values with the explicitly chosen all-zero or −1 handling.

Read the result

One-hot columns indicate categories; ordinal numbers follow the tool's lexical ordering and do not prove a meaningful rank or equal distance. Missing values form an explicit category. Source columns remain alongside added fields so you can review the transformation.

A mistake to avoid

Fit only on training data and reuse the saved mapping for evaluation or deployment. Re-fitting separately can silently change code meanings, and an all-zero row can be ambiguous without the unknown-value policy. Check category and output-column limits before exporting a dataset.

Prepare the input

Create reusable one-hot or ordinal category mappings.

CSV, TSV and arrays of scalar JSON objects are supported. Identifiers stay text. Empty cells are missing by default; add special missing tokens only if their meaning is certain. Use the sample to inspect the exact workflow.

Review the method

Fit categories from training input only, or apply a saved mapping to another dataset. Lexical category ordering is explicit, not semantic. Unknown values can error or map to all-zero / -1. Missing values are treated as an explicit category. Outputs preserve source columns and add encoded fields; maximum 50 categories per column and 64 total columns.

Keep the useful output

Review the summary and result records. Transformation tools retain separate change, rejected-record or diagnostics datasets where relevant. Choose the dataset before exporting; a report and a cleaned dataset serve different purposes.

CSV exports protect formula-like text. JSON keeps data portable without making an Excel workbook. Reports and editable backups may contain private source values; download only what you intend to share. No automatic account storage or server processing is used.

Ready to apply this workflow?

Try Categorical Data Encoder →

Explore a related workflow

All practical guides →

Found unclear instructions or an unexpected result? Contact Team Edtoolkits.

YOUR BROWSER, YOUR CHOICE