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
















