induwara.lk
induwara.lkMachine learning · Metrics

Tversky Index Calculator

Compute the Tversky index and Tversky loss from TP, FP and FN with tunable α and β weights — and see the same prediction scored as Dice and Jaccard/IoU side by side. Runs entirely in your browser, nothing uploaded.

By Induwara AshinsanaUpdated Jul 13, 2026
Tversky indexTP / (TP + α·FP + β·FN)
Collapses to Dice & Jaccard · verified

Correct overlap: |P ∩ G|

Predicted, not in truth: |P ∖ G|

Missed positives: |G ∖ P|

Higher α favours precision · range 02

Higher β favours recall · range 02

PresetsCustom
Tversky index
0.702
70.18%
Tversky loss
0.298
1 − index (minimised in training)
Dice (α=β=0.5)
0.727
F1 / Dice reference
Jaccard (α=β=1)
0.571
IoU reference

Substituted formula

80 / (80 + 0.3·20 + 0.7·40) = 80 / 114 = 0.702
α·FP = 6 · β·FN = 28 · loss = 1 − 0.702 = 0.298

Where your weighting sits

Metricα / βScoreLoss (1 − score)
Dice / F10.5 / 0.50.7270.273
Your Tversky0.3 / 0.70.7020.298
Jaccard / IoU1 / 10.5710.429
Interpretation
β > α weights false negatives (missed positives) more heavily than false positives, so the score favours recall — the usual choice when a model under-segments small targets. With α + β = 1 this is the Salehi et al. training convention.
Computed in your browser — nothing is uploaded.

How it works

The Tversky index scores how well a predicted set P matches a ground-truth set G. In classification and segmentation terms it is built from three counts:

  • TP = |P ∩ G| — true positives, the correct overlap.
  • FP = |P ∖ G| — false positives, predicted but not in truth.
  • FN = |G ∖ P| — false negatives, truth positives the model missed.

The index, introduced by Amos Tversky in “Features of Similarity” (1977) and cast in this TP/FP/FN form for segmentation by Salehi et al. (2017), is:

TI(α, β) = TP / (TP + α·FP + β·FN)

The weight α scales the false-positive term and β scales the false-negative term. That single asymmetry is the whole point: Dice and Jaccard treat the two error types identically, but on imbalanced data — a small tumour, a thin road, a rare defect — a missed positive usually costs far more than a false alarm. Raising β makes those misses drag the score down, which is exactly the training signal you want.

Two familiar metrics are special cases of this one formula:

  • α = β = 0.5 → Dice / F1: TP / (TP + 0.5·FP + 0.5·FN) = 2·TP / (2·TP + FP + FN)
  • α = β = 1 → Jaccard / IoU: TP / (TP + FP + FN)

The calculator computes both special cases on your exact counts and shows them next to your weighting, so the relationship is visible rather than asserted. The Tversky loss is simply 1 − TI(α, β) — the quantity a network minimises. Salehi et al. adopt the α + β = 1 convention so the two weights trade off directly; the tool flags when your inputs meet it. In Two sets mode, TP/FP/FN are derived by set intersection and difference on the two lists you paste (duplicates collapse to membership), then the identical formula applies. All arithmetic is exact floating point and runs in your browser.

Worked examples

Recall-weighted vs the standard metrics

TP = 80, FP = 20, FN = 40 · α = 0.3, β = 0.7

  1. Denominator: 80 + 0.3·20 + 0.7·40 = 80 + 6 + 28 = 114
  2. Tversky index: 80 / 114 = 0.702 → loss = 0.298
  3. Dice (α=β=0.5): 80 / (80 + 10 + 20) = 80/110 = 0.727
  4. Jaccard (α=β=1): 80 / (80 + 20 + 40) = 80/140 = 0.571
  5. The recall-weighted 0.702 sits below Dice's 0.727 — the 40 missed positives are penalised harder.

Same counts, precision-weighted (weights swapped)

TP = 80, FP = 20, FN = 40 · α = 0.7, β = 0.3

  1. Denominator: 80 + 0.7·20 + 0.3·40 = 80 + 14 + 12 = 106
  2. Tversky index: 80 / 106 = 0.755 → loss = 0.245
  3. Now the 20 false positives dominate the penalty, so the score rises.
  4. 0.702 (recall-weighted) vs 0.755 (precision-weighted) on identical data is the asymmetry Dice and Jaccard cannot express.

Identity and edge cases

verifying the formula collapses correctly

  1. α = β = 0.5 on Example 1's counts reproduces Dice exactly: 0.727.
  2. α = β = 1 reproduces Jaccard exactly: 0.571.
  3. Zero overlap TP=0, FP=5, FN=5, α=β=0.5: 0 / (0 + 2.5 + 2.5) = 0, loss = 1.
  4. Perfect match TP=100, FP=0, FN=0: 100 / 100 = 1, loss = 0 for any α, β.
  5. TP=FP=FN=0 makes the denominator zero — the index is undefined and the tool asks for a non-zero input.

Frequently asked questions

Sources & references

The formula and the Dice/Jaccard special cases were last cross-checked against the primary sources on 2026-07-13. The identity checks (α=β=0.5 → Dice, α=β=1 → Jaccard) are enforced by the calculator's own comparison functions.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.