liveBook · Manning

Indicator variable

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

An indicator variable is a binary variable that records whether a condition such as missingness holds.

An indicator variable is a binary feature that records whether a condition holds. For missing data, it preserves the information that a value was absent, which may itself predict the outcome. section 2.4.2

Use indicator variables when exploring and preparing tabular features:

  • Check missingness with .isna() and count True values, where True behaves as 1 and False as 0. section 2.4.2
  • Create missingness indicators for features with substantial missing data when the missing pattern may carry predictive information. section 2.4.2
  • Handle the missing values themselves separately; models such as deep learning solutions still require numeric imputation. section 2.4.2

Auto MPG missingness check

The Auto MPG data contains 8 missing mpg values and 6 missing horsepower values. These counts identify candidate features for missingness indicators, while the original missing values still need an appropriate treatment. section 2.4.2

(data.isna()
    .sum(axis=0)         
)                   

Inspect the column-level missing-value counts that guide indicator-variable decisions. section 2.4.2

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Defines binary missingness flags, demonstrates counting them, and names Scikit-learn support without detailing indicator construction.
Examples
Uses Auto MPG counts showing eight missing mpg values and six missing horsepower values.
What it assumes
Assumes tabular features and teaches pandas-style boolean missingness checks from zero.
What you can do after
Apply it via Scikit-learn's MissingIndicator after assessing column-level missingness.
How it connects
Connects missing values with feature selection, imputation, predictive patterns, and machine-learning algorithms.

Also explained in

Compare how 4 books explain indicator variable →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.