liveBook · Manning

Weighted average

As explained in Deep Learning with R, Third Edition

A weighted average is an average in which each value contributes according to an associated numerical weight.

A weighted average combines several values while giving each one a different influence. For classifier ensembles, stronger models receive larger weights, so their predictions contribute more to the final result. section 18.1.2

Combining classifier predictions

Suppose four classifiers produce validation predictions. A weighted ensemble can calculate final predictions as 0.5 times model A, 0.25 times model B, 0.1 times model C, and 0.15 times model D. These weights can be optimized on validation data using random search or Nelder–Mead. 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 <- .5*preds_a + .25*preds_b + .1*preds_c + .15*preds_d  #1

Inspect the R-style listing to see unequal weights applied directly to four prediction vectors. section 18.1.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains unequal prediction weights and validation-set optimization, but does not provide a mathematical derivation.
Examples
Uses four classifier prediction vectors combined with weights of 0.5, 0.25, 0.1, and 0.15.
What it assumes
Assumes multiple classifiers and validation data while introducing unequal weighting as an ensemble strategy.
What you can do after
Apply weighted averaging to classifier predictions and tune weights on validation data with random search or Nelder–Mead.
How it connects
Connects weighted averages with model ensembling, classifier predictions, validation data, and ensemble diversity.

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 R, Third Edition. The section links point to the parts of the book it draws on.