liveBook · Manning

Categorical data

As explained in Grokking Machine Learning, Second Edition

Categorical data consists of values selected from a finite set of categories or states.

Categorical data consists of values chosen from a finite set of categories or states, such as cat/dog/bird or spam/ham. Unlike numerical data, its labels are not measurements such as prices, sizes, or weights. section 2.7

Categorical labels commonly appear as prediction targets or input features:

  • Classification models predict a category, such as whether an email is spam or ham. section 2.7
  • Decision trees can split on binary categories, such as a user's platform, or on categories with multiple classes, such as dog/cat/bird. section 9.7
  • Before linear regression, one-hot encoding can turn a feature such as Location into one 0–1 column for each location. section 3.27

Email and housing examples

An email dataset may label each message spam or ham, allowing a model to predict the label of a new message. A housing dataset may contain the categorical feature Location alongside numerical features such as Area and number of bedrooms. section 2.7 section 3.27

Figure 2.2 A supervised learning model predicts the label of a new data point. In this case, the data point corresponds to a dog, and the supervised learning algorithm is trained to predict that this data point does, indeed, correspond to a dog.

Follow a supervised prediction from a new data point to its categorical label, using a dog example. section 2.7

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Defines finite categories, contrasts them with numerical data, and shows encoding and decision-tree handling without deeper representation theory.
Examples
Uses animal labels, spam detection, user platforms, dog/cat/bird features, and housing locations as concrete examples.
What it assumes
Distinguishes categories from numerical measurements while introducing both types from basic supervised-learning examples.
What you can do after
Apply it via classification, decision-tree splits, or one-hot encoding before training a linear regression model.
How it connects
Connects categorical data to supervised learning, classification, decision trees, numerical data, one-hot encoding, and linear regression.

Also explained in

Compare how 17 books explain categorical data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning, Second Edition. The section links point to the parts of the book it draws on.