liveBook · Manning

Class-balanced loss

As explained in Build AI Drug Discovery Pipelines

A class-balanced loss is a training loss whose contributions are weighted to compensate for unequal class frequencies.

Class-balanced loss weights each class's contribution to training so models focus more on minority-class patterns when data are imbalanced. A common choice uses the inverse class distribution: wi = N/Ni, where N is the total training count and Ni is class i's count. section 5.2.2

Practical choices include:

  • Use inverse-frequency weights when minority examples should receive greater influence. section 5.2.2
  • Derive weights from domain expertise, hyperparameter tuning, or established best practices instead of using inverse frequencies. section 5.2.2
  • Compare weighting with oversampling and undersampling, then evaluate using validation PR AUC rather than training performance alone. section 5.2.2

Virtual screening for inhibitors

In a virtual screening pipeline, missing an inhibitor can waste downstream drug-discovery resources. A class-weighted decision tree achieved validation PR AUC 0.736, while a default logistic regressor reached 0.813; training PR AUC of 1 for the trees indicated overfitting. section 5.2.2

wi=N/Ni

The equation makes the inverse-frequency weighting rule explicit. section 5.2.2

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Defines inverse-frequency weighting, discusses alternatives, and compares models, but does not develop a broader optimization treatment.
Examples
Uses cytochrome P450 inhibitor screening, weighted decision trees, resampling strategies, and validation PR AUC comparisons.
What it assumes
Assumes binary classification and class frequencies, while defining why minority classes need greater training influence.
What you can do after
Apply class weights in a decision tree and compare weighting against resampling using validation PR AUC.
How it connects
Connects class imbalance with cost-sensitive learning, oversampling, undersampling, decision trees, logistic regression, and PR AUC.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.