liveBook · Manning

Dummy coding

As explained in Effective Data Analysis

Dummy coding represents a categorical variable as separate binary indicator variables for its categories.

Dummy coding represents a categorical variable as separate binary variables, marking each category with 1 when present and 0 when absent. This lets linear models incorporate categorical data as predictors. section 9.2.1

Use dummy coding thoughtfully when preparing categorical predictors:

  • Encode each day of the week as its own indicator when category-specific effects matter. section 9.2.1
  • Usually omit one category, such as Sunday; all-zero indicators imply the omitted reference category. section 9.2.1
  • Replace detailed categories with a meaningful binary variable when grouped behavior better represents the prediction problem. section 9.2.1

Rat sightings by weekday

A model predicting daily New York City rat sightings can encode day of week with indicators, or use a single weekday variable equal to 1 for Monday through Friday and 0 otherwise. Correlation checks can help assess its relationship with sightings and other predictors. section 9.2.1

Figure 9.24 Dummy-coded variables for each day of the week. The final set of variables for a model will often exclude the last category, which is implied when all other categories are absent.
figure

Inspect the day-of-week indicator layout and the omitted-category convention. section 9.2.1

How Effective Data Analysis covers it

How deep it goes
Defines binary indicators, explains reference-category omission, and compares detailed encoding with a grouped binary alternative.
Examples
Uses day-of-week indicators and a weekday binary variable to model daily New York City rat sightings.
What it assumes
Assumes familiarity with categorical variables, binary values, predictors, and correlations while defining the encoding technique directly.
What you can do after
Apply dummy coding to create categorical predictors and compare detailed indicators with a meaningful binary grouping.
How it connects
Connects categorical variables with linear models, predictors, correlation, collinearity, and feature engineering.

Related concepts

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