liveBook · Manning

Ensemble

As explained in Deep Learning with Python, Third Edition

A technique that combines multiple models or views to improve performance by exploiting complementary errors or representations.

An ensemble pools predictions from several independently trained models to produce a stronger prediction than one model alone. The models may capture different aspects of the data, so their complementary errors can yield a more accurate overall view. section 18.1.2

Average several classifiers

For classification, collect each classifier’s predictions at inference time and average them. Equal averaging is appropriate when the classifiers are roughly equally good; a much weaker model can reduce the ensemble’s quality. section 18.1.2

Practical rules of thumb:

  • Prefer diverse, well-performing models: different architectures, assumptions, or random initializations can contribute different useful perspectives. section 18.1.2
  • Replace equal averaging with a weighted average when model quality differs; learn the weights from validation data. section 18.1.2
  • Treat ensembling as a practical performance-improvement technique, especially when pursuing competition-level results. section 18.0 section 20.4.1
preds_a = model_a.predict(x_val)                                     #1
preds_b = model_b.predict(x_val)                                      #1
preds_c = model_c.predict(x_val)                                      #1
preds_d = model_d.predict(x_val)
final_preds = 0.25 * (preds_a + preds_b + preds_c + preds_d)         #2

The listing shows inference-time prediction pooling: four classifier outputs are added and divided equally to form the final prediction. section 18.1.2

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains prediction averaging, weighted averaging, model diversity, and the danger of including a substantially weaker classifier.
Examples
Uses four classifier predictions, equal averaging, weighted averaging, the blind-men-and-elephant analogy, and Kaggle competitions.
What it assumes
Assumes independently trained, reasonably well-performing models and introduces the ensemble rationale through classification predictions.
What you can do after
Apply it by averaging or weighting classifier predictions at inference time and practice model ensembling through Kaggle competitions.
How it connects
Connects model diversity and validation data with classification, inference, hyperparameter tuning, and validation-set overfitting.

Also explained in

Compare how 11 books explain ensemble →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.