Sub topic 6
Measuring Coverage, Overlap and Conflict
Assume you know basic Python, regular expressions, precision, recall, F1, and supervised text classification. This chapter uses a label matrix: each row is an example, and each column is a labeling function (LF). An LF returns a class or abstains when it lacks evidence.
Why diagnostics matter
Weak supervision uses noisy sources instead of hand-labeling every example. Before combining their votes, inspect what each source actually contributes. A source that labels almost nothing may be accurate but not useful. Sources that always agree may provide little independent information. Sources that often disagree may reveal useful edge cases or unreliable rules.
The main diagnostics are:
| Diagnostic | Meaning | Useful question |
|---|---|---|
| Coverage | Fraction of examples where an LF does not abstain | How many examples does this source label? |
| Overlap | Fraction of examples where two LFs both vote | Do these sources apply to the same examples? |
| Conflict | Fraction of overlapping votes that disagree | How often do these sources contradict each other? |
Coverage for LF \(j\) is:
non-abstaining votes / all examples
For two LFs, overlap is:
examples where both vote / all examples
Conflict is usually calculated only where both LFs vote:
disagreeing shared votes / all shared votes
Reading a label matrix
Suppose -1 means abstain, 0 means negative, and 1 means positive.
positive_words negative_words thanks
Example 1 1 -1 -1
Example 2 -1 0 -1
Example 3 -1 0 1
Example 4 -1 -1 -1The positive_words LF has 25% coverage. The negative_words and thanks LFs each have 50% coverage. The last example receives no votes, so every source abstains on it.
The negative and thanks sources overlap on Example 3. Their labels conflict there because one votes negative and the other votes positive. That conflict may indicate sarcasm, mixed sentiment, or a faulty heuristic.
Computing diagnostics in Python
The following code calculates coverage for each LF and pairwise overlap and conflict.
from itertools import combinations
ABSTAIN = -1
L = [
[1, ABSTAIN, ABSTAIN],
[ABSTAIN, 0, ABSTAIN],
[ABSTAIN, 0, 1],
[ABSTAIN, ABSTAIN, ABSTAIN],
]
names = ["positive_words", "negative_words", "thanks"]
n_examples = len(L)
for column, name in enumerate(names):
coverage = sum(row[column] != ABSTAIN for row in L) / n_examples
print(f"{name}: coverage={coverage:.2f}")
for left, right in combinations(range(len(names)), 2):
shared = [
(row[left], row[right])
for row in L
if row[left] != ABSTAIN and row[right] != ABSTAIN
]
overlap = len(shared) / n_examples
conflict = (
sum(a != b for a, b in shared) / len(shared)
if shared else 0.0
)
print(
f"{names[left]} / {names[right]}: "
f"overlap={overlap:.2f}, conflict={conflict:.2f}"
)A high-conflict pair deserves review. Check examples where the pair disagrees and determine whether one rule needs a narrower condition. Do not automatically remove every conflicting source: disagreement can expose cases that a label model should treat with lower confidence.
Exercise
Two labeling functions share votes on 40 of 100 examples, and disagree on 10 of those shared examples. What are their overlap and conflict rates?
Show answer
Their overlap is 40/100 = 0.40. Their conflict rate is 10/40 = 0.25.