High-cardinality categorical feature
A high-cardinality categorical feature is a categorical feature with many distinct values relative to its dataset or analysis context.
Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI
A high-cardinality categorical feature is a categorical feature with many distinct category values relative to the dataset or available computational resources.
- How it is used
- Guides categorical preprocessing choices before tabular machine-learning pipelines are built.
- How deep it goes
- Defines cardinality, explains encoding failures, and demonstrates mixed encoding pipelines without specifying a fixed universal threshold.
- Examples
- Uses Airbnb neighbourhood, room type, and binned geographic coordinates with 221 and 2,259 distinct values.
- What you can do after
- Apply it via pandas unique-value counts and ColumnTransformer pipelines that assign one-hot, ordinal, or target encoding.
Ensemble Methods for Machine Learning
A high-cardinality categorical feature is a categorical input variable with a large number of distinct categories.
- How it is used
- Guides encoding choices for categorical inputs whose many values make ordinary representations inefficient or misleading.
- How deep it goes
- Defines cardinality, explains sparsity and dirty strings, and demonstrates three similarity or hashing encoders in a predictive pipeline.
- Examples
- Uses ZIP codes, employee job titles, and the Adult data set’s 30-category native-country feature as examples.
- What you can do after
- Apply dirty_cat encoders in a scikit-learn pipeline and compare held-out regression scores.
Read how Ensemble Methods for Machine Learning explains high-cardinality categorical feature →
Related concepts
- mean target encodingaddressed by · Mean target encoding is a categorical encoding technique that replaces each category with the mean of its associated target values.
- partitioning keyconfigures · A partitioning key is a value or attribute used to determine which partition stores or receives a record or data item.
- one-hot encodingcontrasts with · One-hot encoding represents each category as a binary vector or set of indicators with exactly one active component identifying that category.
- low-cardinality categorical featurecontrasts with · A low-cardinality categorical feature is a categorical feature with relatively few distinct values or categories.
- categorical datakind of · Categorical data consists of values representing membership in a discrete set of named or ordered categories rather than measured numerical magnitudes.
- dirty_cataddressed by · dirty_cat is an open-source Python library providing encoders for noisy and high-cardinality categorical string features.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

