Tversky Loss for Segmentation
Tversky loss generalizes Dice with separate knobs for false positives and false negatives, so missing a lesion can cost more than overcalling one.
Why Does This Exist?
Dice punishes a missed lesion pixel exactly as much as an extra guessed pixel, but clinicians do not: a missed tumour is worse than a slightly wide outline. Tversky loss (Salehi et al., 2017) splits the denominator with weights for false positives and for false negatives. Setting , tells training that recall matters more than precision.
Think of It Like This
Airport security versus a dinner guest list
Missing a banned item at security is catastrophic; pulling a clean bag aside costs minutes. Missing a dinner guest's name on the list is a shrug; seating a stranger causes an evening of awkwardness. Tversky is the dial that says which room you are guarding. Lesion screening is airport security: high.
Where it stops: cranking recall forever fills the mask with false alarms, and radiologists stop trusting it.
How It Actually Works
With predictions and truth :
recovers Dice. The focal-Tversky variant raises to concentrate on hard cases. Standard lesion setting: , .
Worked example
, . True-positive mass . False-positive mass . False-negative mass . With , : , loss . Dice on the same numbers gave : Tversky charges more because it prices the of missed lesion mass at each.
Code
# Tversky index on the worked example.p = [0.8, 0.7, 0.1, 0.2]g = [1.0, 1.0, 0.0, 0.0]tp = sum(pi * gi for pi, gi in zip(p, g))fp = sum(pi * (1 - gi) for pi, gi in zip(p, g))fn = sum((1 - pi) * gi for pi, gi in zip(p, g))ti = tp / (tp + 0.3 * fp + 0.7 * fn)print(round(1 - ti, 4))# -> 0.2268Watch Out For
Recall dial stuck at maximum
inflates masks until precision collapses and reviewers reject every prediction. Symptom: great recall, useless precision. Fix: track both on validation and stop at the clinical operating point, typically between and .
Tversky on balanced natural scenes
On Cityscapes-style data the asymmetry buys nothing and destabilizes calibration. Symptom: no gain over Dice plus worse confidence. Fix: reserve Tversky for high-recall medical and defect tasks; use Dice or cross-entropy elsewhere.
The Quick Version
- Tversky generalizes Dice with on false positives and on false negatives.
- is exactly Dice; is the common recall-leaning start.
- Missing-lesion mass is priced higher, so tiny structures get found.
- Focal-Tversky adds a gamma exponent to focus on hard volumes.
- Over-cranking beta destroys precision and reviewer trust.