Skip to content
AI360XpertBeta
Glossary
Definition

Cardinality

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

Think of It Like This

Like counting how many distinct paint colors are on an artist's palette, from a simple black-and-white duo to a sprawling rack of fifty shades.

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.