Skip to content
AI360Xpert
Glossary
Definition

Cardinality

The number of distinct values a column contains — two for a yes/no flag, fifty thousand for a merchant ID.

It's the first thing to check on any categorical column, because the count decides how the column should become numbers. Two values need one binary column, a dozen suit one-hot encoding, and thousands need hashing, target encoding, or a learned embedding.

High cardinality causes two separate problems, which is why it matters more than it sounds. Width: one-hot encoding 50,000 categories produces 50,000 columns. And evidence: a category appearing in twelve rows gives its coefficient twelve rows to learn from, so the fitted value is mostly noise.

A useful sanity check is cardinality against row count. A column with almost as many distinct values as rows is an identifier or free text, whatever its data type suggests.