Tversky Index Calculator

Inputs

Tversky index0.8602
Dice coefficient (alpha = beta = 0.5)0.8421
Jaccard index (alpha = beta = 1)0.7273
Weighted error load13.00
How this was calculated
  1. Inputs: 80 true positives, 20 false positives and 10 false negatives with alpha = 0.30 and beta = 0.70.
  2. Weighted errors: 0.30 x 20 + 0.70 x 10 = 13.00.
  3. Tversky index: 80 / (80 + 13.00) = 0.8602.
  4. Tversky index result: 0.8602 - Dice coefficient 0.8421, Jaccard index 0.7273.

Some overlaps are not symmetric, and a similarity measure that pretends otherwise grades them wrong. Amos Tversky's index, from his 1977 theory of similarity, scores the overlap between a predicted set and a true set while charging separately for the two ways they can disagree: alpha prices each false positive, beta each false negative. Set both weights to 1 and the index is the Jaccard index. Set both to 0.5 and it is the Dice coefficient. Everything between is territory the two famous special cases cannot reach - and it is where most real grading problems live.

Enter the true positives, false positives and false negatives and the two weights, and this calculator returns the Tversky index with the Dice coefficient and Jaccard index alongside, plus the weighted error load the weights produced. The worked examples weight misses above false alarms, run the symmetric Jaccard case, and weight false alarms lightly in a screening-style setup.

Worked examples

Misses cost more than false alarms

(80 · 20 · 10 · 0.3 · 0.7)

Tversky index0.8602
Dice coefficient (alpha = beta = 0.5)0.8421
Jaccard index (alpha = beta = 1)0.7273
Weighted error load13.00

Symmetric weights recover Jaccard

(45 · 5 · 15 · 1 · 1)

Tversky index0.6923
Dice coefficient (alpha = beta = 0.5)0.8182
Jaccard index (alpha = beta = 1)0.6923
Weighted error load20.00

False alarms weighted lightly

(120 · 40 · 20 · 0.25 · 0.75)

Tversky index0.8276
Dice coefficient (alpha = beta = 0.5)0.8000
Jaccard index (alpha = beta = 1)0.6667
Weighted error load25.00

Similarity with asymmetric errors

The formula's denominator is the overlap plus a weighted error bill: TP + alpha x FP + beta x FN. The first worked example bills a segmentation-style problem - 80 true positives, 20 false positives at alpha = 0.30, 10 false negatives at beta = 0.70. The weighted load is 0.30 x 20 + 0.70 x 10 = 13.00, and the index is 80 / (80 + 13.00) = 0.8602. The asymmetry is the opinion, stated in numbers: a missed positive costs more than twice a spurious one here.

Tversky arrived at the weights from psychology, not machine learning. Human similarity judgements are asymmetric - a son resembles his father more than the father resembles the son - because the distinctive features of the smaller set weigh more. The index formalises that: features present in one set and absent in the other are not interchangeable, and alpha and beta are the exchange rates.

The practical consequence is that a Tversky score is meaningless without its weights. The same 80-20-10 counts score 0.8602 at the example's weights, 0.8421 as Dice and 0.7273 as Jaccard - three different grades for one segmentation, each correct under its own pricing of the errors. Report the weights with the score, always.

  • Tversky index = TP / (TP + alpha x FP + beta x FN).
  • Alpha = beta = 1 gives the Jaccard index; alpha = beta = 0.5 gives the Dice coefficient.
  • Beta above alpha prices misses above false alarms - the medical-imaging convention.
  • A Tversky score without its weights is an incomplete report.

Dice and Jaccard as special cases

The second worked example is the Jaccard point of the dial: alpha = beta = 1, counts of 45, 5 and 15, and the index reads 0.6923 - identical to the Jaccard figure in its own supporting values, as it must be. Its Dice coefficient, the alpha = beta = 0.5 reading of the same counts, is 0.8182. The spread between the two famous indices on identical data is the standing demonstration that 'the overlap score' is not one number.

Dice always reads at or above Jaccard on the same counts, because its denominator charges each error only once against a doubled overlap, where Jaccard charges the full union. The Tversky family contains both and explains their relationship: they are two points on a plane of weight choices, and the general index lets a field choose its own point instead of inheriting one by habit.

The third example chooses a screening point: 120 true positives, 40 false positives priced cheaply at alpha = 0.25, 20 false negatives priced at beta = 0.75. The load is 25.00 and the index 0.8276, against a Dice of 0.8000 and a Jaccard of 0.6667. When false alarms cost a re-check and misses cost a missed case, that ordering of priorities is the honest one - and only the general index can state it.

WeightsIndex identityExample 1 (80 / 20 / 10)Example 3 (120 / 40 / 20)
alpha = beta = 1Jaccard index0.72730.6667
alpha = beta = 0.5Dice coefficient0.84210.8000
AsymmetricTversky index0.8602 at 0.30 / 0.700.8276 at 0.25 / 0.75
One set of counts, three grades - 0.7273, 0.8421 and 0.8602. The weights are part of the measurement, not a detail of it.

Worked examples

Example 1: True positives (overlap) 80; False positives 20; False negatives 10; Alpha (FP weight) 0.3; Beta (FN weight) 0.7. Tversky index = 0.8602. Supporting values: Dice coefficient (alpha = beta = 0.5) 0.8421; Jaccard index (alpha = beta = 1) 0.7273; Weighted error load 13.00. Inputs: 80 true positives, 20 false positives and 10 false negatives with alpha = 0.30 and beta = 0.70. Weighted errors: 0.30 x 20 + 0.70 x 10 = 13.00. Tversky index: 80 / (80 + 13.00) = 0.8602. Tversky index result: 0.8602 - Dice coefficient 0.8421, Jaccard index 0.7273.

Example 2: True positives (overlap) 45; False positives 5; False negatives 15; Alpha (FP weight) 1; Beta (FN weight) 1. Tversky index = 0.6923. Supporting values: Dice coefficient (alpha = beta = 0.5) 0.8182; Jaccard index (alpha = beta = 1) 0.6923; Weighted error load 20.00. Inputs: 45 true positives, 5 false positives and 15 false negatives with alpha = 1.00 and beta = 1.00. Weighted errors: 1.00 x 5 + 1.00 x 15 = 20.00. Tversky index: 45 / (45 + 20.00) = 0.6923. Tversky index result: 0.6923 - Dice coefficient 0.8182, Jaccard index 0.6923.

Example 3: True positives (overlap) 120; False positives 40; False negatives 20; Alpha (FP weight) 0.25; Beta (FN weight) 0.75. Tversky index = 0.8276. Supporting values: Dice coefficient (alpha = beta = 0.5) 0.8000; Jaccard index (alpha = beta = 1) 0.6667; Weighted error load 25.00. Inputs: 120 true positives, 40 false positives and 20 false negatives with alpha = 0.25 and beta = 0.75. Weighted errors: 0.25 x 40 + 0.75 x 20 = 25.00. Tversky index: 120 / (120 + 25.00) = 0.8276. Tversky index result: 0.8276 - Dice coefficient 0.8000, Jaccard index 0.6667.

Tversky loss in segmentation networks

The index's second career began when Salehi, Erdogmus and Gholipour turned it into a loss function for training segmentation networks in 2017. Medical images are brutally imbalanced - a lesion may occupy a sliver of the scan - and a Dice-trained network can score well by under-painting. Raising beta above alpha charges the network more for the voxels it missed than for the ones it over-painted, and recall rises to meet the clinical priority.

The calculator's role in that workflow is the audit end: given a trained model's confusion counts on a validation set, it prices the overlap at the same weights the loss used, and at the Dice and Jaccard settings for comparison with the wider literature. A model that wins only at its own weights has told you something narrower than a model that wins across the row.

Choosing alpha and beta

The weights should be chosen from the cost structure of the application, not tuned until the score looks pleasant. Ask what a false positive triggers - a re-check, a biopsy, a wasted journey - and what a false negative forfeits, and set the ratio of beta to alpha to the ratio of those costs. The first example's 0.70-to-0.30 split says a miss costs a little over twice a false alarm; a cancer-screening context might go further, a spam filter much less far.

One convention to hold: keep alpha + beta in a range where the score stays comparable with the Dice point at 0.5 and 0.5, the literature's lingua franca. Extreme weights buy their emphasis by making the number untranslatable to readers who grade with the standard indices - sometimes worth it, never free.

What the index ignores

Like every overlap measure, Tversky counts set membership and nothing else: true negatives never appear, distances never appear, and a false positive adjacent to the target scores exactly like one on the far side of the image. For problems where the vast background of true negatives is itself the achievement - ruling out disease in a healthy population, say - an accuracy-style measure that counts them belongs alongside.

The index also treats the sets as given. It grades a segmentation against a reference standard whose own errors it cannot see. When two human graders disagree with each other at a Tversky of 0.8602 themselves, a model scoring the same against one of them has reached the reference's noise floor, and further weight-tuning is theatre. Knowing the inter-grader number is the mark of a mature evaluation - and it is computed exactly the same way, with this same formula.

FAQs

What Tversky index do 80 true positives, 20 false positives and 10 false negatives give?

At alpha = 0.30 and beta = 0.70, the weighted error load is 13.00 and the index is 80 / (80 + 13.00) = 0.8602. The same counts read 0.8421 as Dice and 0.7273 as Jaccard - the weights are part of the answer.

How is the Tversky index related to Dice and Jaccard?

They are its special cases. Alpha = beta = 1 reproduces the Jaccard index exactly - the second example reads 0.6923 on both - and alpha = beta = 0.5 reproduces the Dice coefficient. Tversky is the plane; they are two points on it.

Why would beta be set above alpha?

When a miss costs more than a false alarm. In medical segmentation a missed lesion can be a missed diagnosis while an over-painted boundary costs a review - the first example's beta of 0.70 against alpha of 0.30 prices a miss at a little over twice a false alarm.

What is the weighted error load?

Alpha times the false positives plus beta times the false negatives - the error bill in the denominator. It is 13.00 in the first example and 25.00 in the third, and it is the quickest way to see what the weights actually did.

Can the Tversky index exceed the Dice coefficient?

Yes, when the weights are kind to the errors you actually made. The first example's asymmetric 0.8602 beats its Dice of 0.8421 because its errors are mostly false positives, which alpha prices cheaply. That is the index working as intended, not an inconsistency.

What does the index leave out?

True negatives and all geometry. It counts set membership only, so it cannot see that a false positive was adjacent rather than distant, and it grades against a reference standard whose own fallibility it cannot measure.

Sources

Related calculators

Dice Coefficient Calculator
The Sorensen-Dice similarity coefficient from two set sizes and their intersection, with the Jaccard index and union size.
Jaccard Similarity Calculator
The Jaccard index of two sets: the size of the overlap divided by the size of the union, with the matching Jaccard distance.
F1 Score and Precision-Recall Calculator
Precision, recall and the F1 score of a classifier from true positives, false positives and false negatives, with the F2 and F0.5 variants that re-weight the two errors.