Notes

Categorical Data

Some pieces of information aren’t really “numbers” in the measuring sense—they’re more like labels. When you record a person’s blood type, a product’s color, or a customer’s subscription plan, you’re working with categorical data.

What it is

Categorical data (also called qualitative data) represents values that fall into distinct groups or categories. The key idea is that the categories are names of groups, not measurements on a numeric scale. You can count how many items fall into each category, but doing arithmetic like “average color” doesn’t make sense.

Main kinds

  • Nominal: categories with no natural order (e.g., {red, blue, green}, {cat, dog}, {USA, Japan}).
  • Ordinal: categories with a meaningful order, but gaps aren’t measurable (e.g., {small, medium, large}, satisfaction ratings {poor, fair, good, excellent}).

Everyday examples

  • House listings: neighborhood name (categorical), heating type (categorical), condition grade (often ordinal).
  • Healthcare: diagnosis code, smoker/non-smoker, pain level (ordinal).
  • Retail: payment method, product category, membership tier (ordinal if tiers are ordered).

Why it matters in AI/ML

Most ML models expect numeric inputs, so categorical features usually need encoding:

  • One-hot encoding for nominal categories (common in scikit-learn).
  • Ordinal encoding when order matters.
  • Target encoding or learned embeddings for high-cardinality categories (e.g., thousands of product IDs).

Handling categorical data well can dramatically affect performance: a bad encoding can invent fake “distances” between categories or cause leakage, while a good one lets models capture real group differences.

Categorical Data are values that represent discrete groups or labels rather than numeric magnitudes. They can be nominal (no inherent order, e.g., color) or ordinal (ordered categories, e.g., low/medium/high). In AI/ML, categorical variables often require encoding (one-hot, ordinal, target encoding) to be used in models and strongly influence feature engineering, bias, and interpretability. Example: “payment_method” with {card, cash, transfer}.

Think of sorting laundry: you put socks in one pile, shirts in another, and towels in a third. You’re not measuring anything—you’re just grouping items by type. That’s what categorical data is: information that falls into named groups or labels.

In statistics and machine learning, categorical data includes things like “red/blue/green,” “spam/not spam,” or “cat/dog.” Sometimes the categories have no natural order (like colors). Other times they do (like “small/medium/large”). Many AI models can’t use these labels directly, so they’re often converted into numbers in a careful way.