liveBook · Manning

Rare category

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

A rare class is a target category represented by a small proportion of observations in a dataset.

A rare category is a categorical value that occurs infrequently or has very few instances in a dataset. Such categories can make a model overfit during training, so they should be identified early, ideally during data extraction. section 2.2.5

Handle rare categories by:

  • Aggregating similar rare categories into a larger class, using domain knowledge to decide which values belong together. section 2.2.5
  • Distinguishing rarity from high cardinality: too many labels may call for target encoding or embeddings rather than simple aggregation. section 2.2.5
  • Inspecting categorical distributions during exploratory analysis, alongside value counts and other checks for tabular-data problems. section 2.5

A practical encoding decision

Suppose a categorical feature contains several labels that appear only a few times. Combine genuinely similar labels into a broader category when domain knowledge supports that choice. If the feature instead contains many labels overall, consider target encoding for gradient boosting or embeddings for deep learning. section 2.2.5

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

How deep it goes
Defines rarity, explains its overfitting risk, and recommends aggregation while deferring implementation details to later methods.
Examples
Uses infrequently occurring labels, domain-guided category aggregation, target encoding, and embeddings as concrete treatments.
What it assumes
Assumes familiarity with categorical variables and introduces rarity as infrequent category occurrence within a dataset.
What you can do after
Apply domain knowledge to aggregate similar rare labels and distinguish that remedy from encodings for high-cardinality features.
How it connects
Connects categorical variables with overfitting, domain knowledge, target encoding, embeddings, gradient boosting, and deep learning.

Also explained in

Compare how 3 books explain rare category →

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.