liveBook · Manning

Categorical data

As explained in Grokking Machine Learning

Data whose values belong to a finite set of named categories or states.

Is a type of data whose values come from a finite set of categories, or states. A label such as “cat” or “dog” is categorical; a weight such as 4.2 is numerical. In supervised learning, models that predict categories are called classification models. section 2.2 section 2.2

Categorical values can appear as labels or as features:

  • Animal type (cat or dog) and email status (spam or ham) are categorical labels. section 2.2
  • Gender and port of embarkation are categorical features in passenger data. section 13.3
  • One-hot encoding converts categorical features to numbers; binning can turn numerical features into categories. section 13.3
Figure 13.1 One-hot encoding our data to turn it all into numbers for the machine learning model to read. On the left, we have columns with categorical features such as gender or port of embarkment. On the right, we have turned these categorical features into numerical features.

Compare categorical feature columns with their numerical representation after one-hot encoding. section 13.3

How Grokking Machine Learning covers it

How deep it goes
Defines finite categories and names one-hot encoding and binning as ways to convert between categorical and numerical representations.
Examples
Uses animal types, spam or ham labels, gender, and passenger embarkation ports as examples.
What you can do after
Apply one-hot encoding to categorical features or bin numerical features into categories before model training.
How it connects
Connects categorical data to supervised learning, classification, numerical data, feature engineering, one-hot encoding, and binning.

Also explained in

Compare how 16 books explain categorical data →

Related concepts

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