liveBook · Manning

Class imbalance

Class imbalance is a condition in a classification dataset where classes have substantially unequal numbers of examples.

How 11 Manning books explain it

Machine Learning System Design

A condition in which the frequencies of classes in a classification dataset or population differ substantially.

How it is used
Guides training, metric selection, and dataset preparation when positive and negative classification examples occur at unequal rates.
How deep it goes
Explains loss and metric tradeoffs through cases, but stops short of a procedure for tuning sampling or focal loss.
Examples
Uses changing fraud rates, rare offer purchases, and unequal search impressions, clicks, and purchases.
What you can do after
Evaluate/understand it by checking class counts, interpreting metrics against changing class balance, and considering imbalance-aware losses or proxy targets.

Read how Machine Learning System Design explains class imbalance →

Financial AI in Practice

A condition in which a classification dataset has substantially different numbers of observations in its classes.

How it is used
Guides target inspection, model training, and evaluation when rare financial outcomes matter more than majority-class accuracy.
How deep it goes
Explains majority-class bias and compares resampling with cost-sensitive learning, while leaving detailed implementation of those remedies undeveloped.
Examples
Uses a 492-in-284,807 fraud dataset, a 74% nondefault credit target, and a roughly 75% neutral market target.
What you can do after
Diagnose/debug with it by counting target classes, questioning high accuracy, and selecting imbalance-aware training and evaluation options.

Read how Financial AI in Practice explains class imbalance →

Grokking Statistics

An imbalanced dataset has substantially unequal numbers of observations across its classes.

How it is used
Evaluates rare-event classification when majority-class accuracy gives a falsely reassuring result.
How deep it goes
Explains imbalance through confusion-matrix outcomes, precision, recall, thresholds, and ROC-versus-PRC metric choice.
Examples
Uses rare wolves, non-spam versus spam email, and toddler meltdowns to illustrate uneven classes and threshold choices.
What you can do after
Evaluate/understand imbalanced classifiers by rejecting accuracy alone and comparing precision, recall, and PRCs.

Read how Grokking Statistics explains class imbalance →

Graph Neural Networks in Action

Class imbalance is a property of a classification dataset in which the classes contain substantially different numbers of examples.

How it is used
Flags uneven node-label distributions that can obscure performance on rare classes in product categorization and fraud detection.
How deep it goes
Moves from class counts and diagnostic metrics to balanced-batch sampling, while outlining other remedies without implementing them.
Examples
Uses Amazon Products category counts, a fraud-detection GATv2–XGBoost comparison, and a balanced node sampler.
What you can do after
Diagnose/debug with class counts and minority-class metrics, then apply balanced-batch sampling while checking graph-specific trade-offs.

Read how Graph Neural Networks in Action explains class imbalance →

Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

Imbalanced data has substantially unequal representation of classes or outcome groups.

How it is used
Guides classifier evaluation and algorithm selection when outcome classes have unequal representation.
How deep it goes
Compares balanced and imbalanced target counts, recommends evaluation metrics, and briefly explains ExtraTrees handling without detailing resampling.
Examples
Uses binary price targets split at the mean and median, with explicit class counts and an ExtraTrees classifier pipeline.
What you can do after
Evaluate classifiers with metrics suited to class proportions and test ExtraTrees when minority signals may be overlooked.

Read how Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI explains class imbalance →

Ensemble Methods for Machine Learning

Class imbalance is a data-distribution condition in which the classes contain substantially different numbers of examples.

How it is used
Guides metric selection and custom loss design when minority-class errors matter more than aggregate accuracy.
How deep it goes
Explains the distributional problem, error tradeoffs, imbalance-aware metrics, and focal-loss implementation with gradient boosting.
Examples
Uses dense object detection, medical diagnosis, spam detection, and Bank Marketing subscription prediction as concrete cases.
What you can do after
Apply it via balanced accuracy, recall, stratified splitting, and focal loss to build or evaluate models under skewed class frequencies.

Read how Ensemble Methods for Machine Learning explains class imbalance →

Deep Learning with PyTorch, Second Edition

A dataset in which class frequencies are heavily skewed toward one class.

How it is used
Diagnoses why a nodule classifier achieves high accuracy while predicting only the majority class.
How deep it goes
Explains majority-class failure, quantifies false positives, and demonstrates balanced training without detailing sampling internals.
Examples
Uses nodule detection, a 400:1 negative-to-positive dataset, false-positive arithmetic, and balanced LUNA training metrics.
What you can do after
Diagnose misleading accuracy and evaluate minority-class performance using class-specific metrics and balanced training data.

Read how Deep Learning with PyTorch, Second Edition explains class imbalance →

Graph Algorithms for Data Science

Class imbalance is a condition in which classes in a classification dataset occur with substantially unequal frequencies.

How it is used
Balances link-prediction classification samples so models learn to identify relationships instead of defaulting to nonrelationships.
How deep it goes
Explains scaling, majority-class accuracy, minority-class errors, and negative-example subsampling, but does not develop broader imbalance methods.
Examples
Uses sparse social-network pairs, approximately 99% majority-class accuracy, and an exercise targeting 13,082 negative samples.
What you can do after
Apply negative-example subsampling to create approximately balanced link-prediction classification samples.

Read how Graph Algorithms for Data Science explains class imbalance →

Statistics Every Programmer Needs

Class imbalance is a condition in which classes in a labeled dataset have substantially unequal representation.

How it is used
Diagnoses why classification models favor one class and motivates class-level evaluation instead of relying only on overall accuracy.
How deep it goes
Defines majority-class bias and demonstrates class-specific accuracy, but stops short of prescribing imbalance remedies.
Examples
Uses fourth-down conversion predictions, confusion matrices, and separate accuracy calculations for labels 0 and 1.
What you can do after
Evaluate classification performance by class using confusion matrices and class-specific accuracy calculations.

Read how Statistics Every Programmer Needs explains class imbalance →

Inside Deep Learning: Math, Algorithms, Models

A dataset condition in which some classes occur much more frequently than others.

How it is used
Uses stratified sampling to preserve class ratios and reduce misleading evaluation from imbalanced train/test splits.
How deep it goes
Defines uneven class ratios, explains majority-label bias, and stops short of broader imbalance methods.
Examples
Uses cancer prediction, 99:1 class ratios, and a name-language classification dataset as concrete examples.
What you can do after
Apply it via scikit-learn stratified sampling when creating train/test splits.

Read how Inside Deep Learning: Math, Algorithms, Models explains class imbalance →

Outlier Detection in Python

Class imbalance is a distribution in which one or more target classes contain far fewer observations than another class.

How it is used
Frames rare labeled classes as a test case for comparing classification and outlier-detection behavior.
How deep it goes
Explains how imbalance changes detection difficulty and evaluation, without developing a rebalancing or detector procedure.
Examples
Uses the labeled KDD Cup network dataset, rare attacks, and tabular connection features as concrete examples.
What you can do after
Evaluate outlier detectors on labeled imbalanced data while interpreting dataset fit, masking, and generalization limitations.

Read how Outlier Detection in Python explains class imbalance →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.