Sub topic 9
From Votes to Probabilistic Labels
Assume you know Python, basic supervised text classification, precision, recall, F1, and elementary probability. This chapter assumes that labeling functions already produce class votes or abstentions.
A labeling function is a noisy rule that labels some examples and abstains on others. For example, a rule that finds “refund” might vote for negative. Several rules produce a label matrix. Each row represents one text, and each column represents one labeling function.
Why majority vote is only a baseline
A simple approach counts the non-abstaining votes. The most common class becomes the label. This works when sources have similar accuracy and their errors are mostly independent.
The approach fails when one source is much better or worse than the others. It also fails when several sources repeat the same evidence. Three rules that all search for the same word do not provide three independent pieces of evidence.
| Text | Positive votes | Negative votes | Majority result |
|---|---|---|---|
| “Great battery” | 2 | 0 | positive |
| “Broken and terrible” | 0 | 2 | negative |
| “It works, but I want a refund” | 1 | 1 | abstain |
A tie can be marked as ABSTAIN instead of forcing an incorrect class. However, majority vote does not estimate how trustworthy each source is.
Label models estimate source reliability
A label model is a probabilistic model that learns how labeling functions behave. It estimates each source’s accuracy, coverage, and relationships with other sources. It can then assign a probability to every class.
For a binary sentiment task, the output for one text might be:
- positive:
0.92 - negative:
0.08
These are called soft labels or probabilistic labels. A hard label stores only positive. A soft label preserves uncertainty, which is useful when the votes conflict.
In a simplified model, a source that often agrees with other reliable sources receives more weight. A source that frequently contradicts them receives less weight. Real label models use statistical assumptions, often including conditional independence or learned dependency corrections. These assumptions are approximations, so validation remains necessary.
from collections import Counter
ABSTAIN, NEG, POS = -1, 0, 1
label_rows = [
[POS, POS, ABSTAIN],
[NEG, NEG, ABSTAIN],
[POS, NEG, POS],
[ABSTAIN, ABSTAIN, ABSTAIN],
]
def vote_probabilities(row):
votes = [v for v in row if v != ABSTAIN]
if not votes:
return {NEG: 0.5, POS: 0.5}
counts = Counter(votes)
total = len(votes)
return {
NEG: counts[NEG] / total,
POS: counts[POS] / total,
}
for row in label_rows:
print(vote_probabilities(row))This code creates vote proportions, not a trained label model. A real label model may produce different probabilities because it estimates source quality rather than treating every vote equally.
Using probabilistic labels
After fitting a label model, use its class probabilities in one of two ways:
- Keep only examples whose highest probability exceeds a threshold, such as
0.9. - Train the end classifier with the full probability vector, if the classifier supports soft targets.
The first option reduces noise but discards data. The second option retains more data but requires compatible training code. In both cases, do not evaluate on the same weakly labeled examples used for training.
Exercise
Three labeling functions vote positive, positive, and negative. What are the simple vote proportions, and why might a label model produce different values?
Show answer
The proportions are positive 2/3 and negative 1/3. A label model may produce different values after estimating that one source is more accurate, less accurate, or correlated with another source.