liveBook · Manning

Weighted average

As explained in Deep Learning with Python, Third Edition

An averaging operation that assigns different weights to different values before combining them into a single result.

A weighted average combines several values while giving each one a chosen influence. In classifier ensembling, it pools model predictions instead of trusting a single model. section 18.1.2

Equal versus learned influence

Four classifier outputs can receive equal influence by multiplying their combined predictions by 0.25. A smarter ensemble might give weights of 0.5, 0.25, 0.1, and 0.15, usually favoring stronger classifiers. section 18.1.2

Use these practical rules:

  • Learn ensemble weights on validation data rather than assuming every classifier is equally good. section 18.1.2
  • Search for weights with random search or the Nelder–Mead optimization algorithm. section 18.1.2
  • Prioritize model diversity: differently biased classifiers can cancel one another’s errors, while similarly biased models preserve the same weakness. section 18.1.2
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

Shows the equal-weight implementation for combining four validation predictions. section 18.1.2

preds_a = model_a.predict(x_val)
preds_b = model_b.predict(x_val)
preds_c = model_c.predict(x_val)
preds_d = model_d.predict(x_val)
final_preds = 0.5 * preds_a + 0.25 * preds_b + 0.1 * preds_c + 0.15 * preds_d#1

Shows unequal weights that assign different influence to four classifier predictions. section 18.1.2

How Deep Learning with Python, Third Edition covers it

How deep it goes
Defines equal and learned weighting, demonstrates implementation, and stops short of deriving the optimization algorithms.
Examples
Uses four classifier prediction arrays with equal weights and with weights of 0.5, 0.25, 0.1, and 0.15.
What it assumes
Assumes classifier predictions and validation data, while introducing ensemble weighting and model diversity through examples.
What you can do after
Apply it via validation-data weight optimization to combine classifier predictions into a strong ensemble baseline.
How it connects
Connects ensemble learning with classifier predictions, validation data, optimization, model diversity, bias, and inference.

Also explained in

Compare how 5 books explain weighted average →

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.