Notes

Weighted Average

When your dataset has one class that shows up a lot (like “not fraud”) and another that’s rare (like “fraud”), a single performance number can hide what’s really happening. A weighted average is a way to combine multiple scores into one, while giving more influence to the parts that represent more data (or more importance).

What “weighted average” means in evaluation

A weighted average combines values using weights that sum to 1 (or are normalized). In imbalanced classification, the most common use is to average a metric (like precision, recall, or F1) across classes while weighting each class by its support (the number of true examples in that class). For two classes, it looks like:

weighted_metric = (n0 * metric0 + n1 * metric1) / (n0 + n1)

This is different from a macro average, which gives each class equal weight, and a micro average, which pools all decisions before computing the metric.

Why it matters for imbalanced data

Weighted averaging can produce a stable “single number,” but it can also be misleading: the majority class can dominate the result. In fraud detection, a model can have a strong weighted F1 mainly by doing well on “not fraud,” while still missing many fraud cases (low minority-class recall). Weighted averages are useful when overall performance proportional to class frequency is the goal, but they should be read alongside per-class metrics.

Where you’ll see it in practice

  • scikit-learn classification reports: average="weighted" in precision_score, recall_score, and f1_score.
  • Customer churn or disease screening dashboards that report a single F1 while still tracking minority-class recall separately.

A weighted average is an aggregate computed by multiplying each value by an associated weight (importance or frequency), summing these products, and dividing by the sum of weights. In supervised learning evaluation—especially with imbalanced classes—it combines per-class metrics (e.g., precision, recall, F1) in proportion to class support or specified costs, yielding a single score that reflects the desired emphasis and avoids misleading unweighted summaries.

Imagine you’re grading a course where homework counts for 20%, a midterm for 30%, and a final exam for 50%. You don’t just take the plain average—you take a weighted average, where some parts matter more than others.

In AI, a weighted average is a way to combine several numbers while giving extra importance to the ones you care about most. This is especially useful when evaluating models on imbalanced data, like fraud detection, where “not fraud” is common and “fraud” is rare. You might weight the rare class more so the final score reflects what really matters, not just what’s most frequent.