AI Glossary / AI and machine learning / Beginner
Categorical data
Definition
Categorical data is data that names a group or label rather than measuring an amount, such as country, product type, plan level or payment method.
What it means
Most business data is a mix of numbers and labels. Revenue is a number; region, channel and product line are categories. Models and reports treat the two kinds differently.
There are two flavors. Nominal categories have no natural order, such as country or color. Ordinal categories have one, such as small, medium and large, or a satisfaction scale from poor to excellent.
Some columns look numeric but are really categories. Customer IDs, postcodes and product codes are labels printed as digits; averaging them is nonsense, and a model that treats them as amounts invents patterns that do not exist.
Models need numbers, so categories must be encoded. The common encodings are one-hot columns, one per category, ordinal numbering where order is real, and learned embeddings when there are thousands of labels.
For a business, the main risks are mistaking labels for numbers, drowning in high-cardinality columns such as ten thousand product codes, and meeting a label at prediction time that training never saw.
Dates are a special case. A date can be treated as a number for trends, or exploded into categories such as day of week and month, which often carry the real business pattern.
How it works
Inspect each column and decide: true number, nominal category, ordinal category, or identifier. A data dictionary that records this decision prevents most downstream mistakes.
Encode for the model. One-hot encoding adds a yes-or-no column per category; ordinal encoding maps small, medium, large to 1, 2, 3 only because the order is genuine.
Handle high cardinality deliberately: group rare labels into an other bucket, or use embeddings, which give each frequent label a compact set of learned numbers.
Plan for unseen labels. A model deployed in France will one day meet a new country; decide whether it maps to other, gets a default, or triggers a retraining review.
Keep the original labels alongside any encoding, so reports stay readable and the mapping is auditable.
One caution with ordinal encoding: numbering categories 1, 2, 3 lets the model assume equal spacing between them, which is fine only when that spacing is meaningful.
Three practical examples
- Nominal: sales region, marketing channel, payment method, supplier name.
- Ordinal: T-shirt sizes, satisfaction ratings, priority levels low, medium, high.
- Numeric impostors: customer ID, postcode, SKU code, phone extension.
Think of it this way
Think of coat-check tickets. Ticket 214 and ticket 215 are not one apart in any meaningful sense; the numbers are just names. Treating them as amounts is like averaging the tickets and expecting to find the average coat.
The limit: some labels carry order, like education levels, and forgetting that throws away real information. Know which kind of label you hold.
Worked example
the plan column that pretended to be a number
Suppose a subscription firm stores plan as 1, 2 and 3 for basic, standard and premium, and feeds it to a churn model as a number.
The model concludes that churn rises smoothly with the plan number, an artifact of the coding. Basic and premium differ, but the smooth line is fiction. The example is illustrative.
An analyst re-encodes plan as three one-hot columns. The model now learns a separate effect for each plan, and the false gradient disappears from the explanations.
The fix costs an afternoon; the wrong version had been steering retention offers for a quarter.
Illustrative case study
A fictional retailer adds its 12,000-product catalog to a demand model with one-hot encoding. The model balloons, training slows, and rare products get unreliable columns.
The team groups the 11,000 rarest products into category-level labels and keeps one-hot only for the top sellers. Accuracy holds, training is fast, and reports become readable.
The invented lesson: cardinality is a design decision. More detail is not more signal when each detail has three examples.
The retailer also adds an explicit unknown bucket so future odd values map somewhere safe instead of crashing the pipeline.
Common misconceptions and mistakes
- Categories can be averaged. The average of France and Japan, or of plans 1 and 3, is meaningless.
- Any numeric column is a number. IDs and codes are labels that happen to be printed in digits.
- One-hot encoding is the only option. Ordinal encoding and embeddings fit many cases better, especially with order or high cardinality.
Business use
Keep a data dictionary that marks each column as numeric, nominal, ordinal or identifier, and review it when new columns appear.
Ask how a model handles labels it has never seen; the answer matters the day you launch in a new region or add a product line.
When merging data from two systems, align category spellings first; UK, U.K. and United Kingdom are three categories to a computer and one to you.
People also ask
What is the difference between nominal and ordinal?
Nominal labels have no natural order, like country; ordinal labels do, like small, medium, large.
What is one-hot encoding?
One yes-or-no column per category, so a record from France has 1 under France and 0 elsewhere.
How many categories are too many for one-hot?
There is no hard line, but beyond a few hundred, grouping or embeddings usually work better.
Can I turn categories into counts?
Frequency encoding replaces each label with how common it is. It works sometimes, but loses the label's identity; test it against one-hot.
Check your understanding
Why is feeding customer ID into a model as a number a mistake?
Answer: The digits are labels, not amounts, so the model invents false orderings and distances between customers that carry no meaning.
Related terms
- One-hot encoding
- Cardinality (data modeling)
- Embedding
- nominal
- ordinal
- cardinality
- data dictionary
Learn next
AI for Business Owners covers how to get business data ready for reliable models and reports: https://aiforbusinessandlife.com/academy/ai-for-business-owners. [C2]
More in AI and machine learning
- Canonical correspondence analysis - Canonical correspondence analysis is a constrained ordination method that relates a table of species abundances, or similar non-negative response data, to...
- Cascading classifiers - Cascading classifiers are classification stages arranged so that an example's result at one stage determines whether it proceeds to another.
- Case-based reasoning - Case-based reasoning is an approach to problem solving that uses relevant past cases to help address a new situation.
- Category utility - Category utility is a score for judging how informative a grouping is.
- Centroid - A centroid is the center point of a group of data, found by averaging the group's values on each measure, and used to represent the whole group with one...
- Centroid-based clustering - Centroid-based clustering groups data by assigning every point to the nearest center, or centroid, with k-means the best-known method, producing a chosen...
Sources
[S2] Google, Machine Learning Glossary. Full URLs are in the source ledger. Verified 11 October 2026.
Previous: Categorial grammar Next: Categorical Naive Bayes