Skip to content
svgstacking-weights

Ensemble weights

How much does each member contribute to the ensemble?

Demo data · seed 20261101 · 4 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read each bar as the member's share of the ensemble.
  2. “Not used” members add nothing beyond the others.
  3. Don't read a weight as a member's quality: correlated members share weight.
  1. Callout 1: The largest share.
  2. Callout 2: Not used: nothing to add beyond the others.

Watch out

  • Weights shift with small data changes when members are similar.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Draws the run's numbers as given (computed by the host's cs-ml evaluation or the Python/R engine); the chart computes nothing statistical.
  • Weights sum to one. Stacking weights are non-negative least-squares coefficients on out-of-fold predictions, normalized (SuperLearner's NNLS).
# Ensemble weights — Codesplash Chart Lab (recipe "stacking-weights")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("stacking-weights-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

L = "member"
W = "weight"
d = df[[L, W]].dropna().sort_values([W, L], ascending=[True, False])  # largest on top
fig, ax = plt.subplots(figsize=(7, 0.5 * len(d) + 1.2))
ax.barh(d[L].astype(str), d[W], color=PALETTE[0])
for y, w in enumerate(d[W]):
    ax.text(w, y, f" {w:.1%}" if w > 0 else " not used", va="center", fontsize=8)
ax.xaxis.set_major_formatter(lambda v, _: f"{v:.0%}")
ax.set_xlabel("Share of the ensemble")
plt.show()

Needs pandas, numpy, matplotlib · reads stacking-weights-demo.csv · app theme from the optional codesplash helper