16
$\begingroup$

I come across the Dice coefficient for volume similarity (https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient) and accuracy (https://en.wikipedia.org/wiki/Accuracy_and_precision).

It seems to me that these two measures are the same. Any thoughts?

$\endgroup$
3
21
$\begingroup$

These are not the same thing and they are often used in different contexts. The Dice score is often used to quantify the performance of image segmentation methods. There you annotate some ground truth region in your image and then make an automated algorithm to do it. You validate the algorithm by calculating the Dice score, which is a measure of how similar the objects are. So it is the size of the overlap of the two segmentations divided by the total size of the two objects. Using the same terms as describing accuracy, the Dice score is: $$ \text{Dice score} = \frac{2\cdot \text{number of true positives}}{2 \cdot \text{number of true positives + number of false positives + number of false negatives}} $$ So the number of true positives, is the number that your method finds, the number of positives is the total number of positives that can be found and the number of false positives is the number of points that are negative that your method classifies as positive.

The Dice score is not only a measure of how many positives you find, but it also penalizes for the false positives that the method finds, similar to precision. so it is more similar to precision than accuracy. The only difference is the denominator, where you have the total number of positives instead of only the positives that the method finds. So the Dice score is also penalizing for the positives that your algorithm/method could not find.

Edit: In the case of image segmentation, let's say that you have a mask with ground truth, let's call the mask $A$ like you suggest. So the mask has values 1 in the pixels where there is something you are trying to find and else zero. Now you have an algorithm to generate image/mask $B$, which also has to be a binary image, i.e. you create a mask for you segmentation. Then we have the following:

  • Number of positives is the total number of pixels that have intensity 1 in image $A$
  • Number of true positives is the total number of pixels which have the value 1 in both $A$ and $B$. So it the intersection of the regions of ones in $A$ and $B$. It is the same as using the AND operator on $A$ and $B$.
  • Number of false positives is the number of pixels which appear as 1 in $B$ but zero in $A$.

If you are doing this for a publication, then write Dice with a capital D, because it is named after a guy named Dice.

EDIT: Regarding the comment about a correction: I do not use the traditional formula to calculate the Dice coefficient, but if I translate it to the notation in the other answer it becomes:

$$ \text{Dice score} = \frac{2\cdot|A\cap B|}{2\cdot|A\cap B| + |B\backslash A| + |A\backslash B|} $$

Which is equivalent to the traditional definition. It is more convenient to write it the way I wrote it originally to state the formula in terms of false positives. The backslash is the set minus.

$\endgroup$
7
  • 2
    $\begingroup$ Thanks for the reply. Exactly for image segmentation comparison. So, this dice score is used, let say, give image A and image B. Image A is the ground true (0 or 1), and image B is my segmentation. So, what is the total number of positives(1), is that the number of 1 in A + number of 1 in B?? I am a bit confused here. Same as false positive $\endgroup$ – RockTheStar Feb 11 '16 at 17:45
  • 1
    $\begingroup$ @RockTheStar I'll edit my answer to account for image segmentation. $\endgroup$ – Gumeo Feb 11 '16 at 17:53
  • 1
    $\begingroup$ Great, thanks a lot for your explanation. One more follow-up question. What about the range of D? Is that between 0 and 1? $\endgroup$ – RockTheStar Feb 11 '16 at 19:52
  • 2
    $\begingroup$ Great, thanks! Will implement this and look at the result $\endgroup$ – RockTheStar Feb 11 '16 at 20:11
  • 2
    $\begingroup$ @Gumeo you might want to fix or at least explain your answer, please see my new answer for details $\endgroup$ – dvb Dec 31 '16 at 19:36
24
$\begingroup$

The Dice coefficient (also known as Dice similarity index) is the same as the F1 score, but it's not the same as accuracy. The main difference might be the fact that accuracy takes into account true negatives while Dice coefficient and many other measures just handle true negatives as uninteresting defaults (see The Basics of Classifier Evaluation, Part 1).

As far as I can tell, the Dice coefficient isn't computed as described by a previous answer, which actually contains the formula for the Jaccard index (also known as "intersection over union" in computer vision).

$$ \begin{align*} Dice(A,B) &= \frac{2|A\cdot B|}{ |A| + |B| } \\ F1(A,B) &= \frac{2}{|A|/|A \cdot B| + |B|/|A\cdot B|} \\ Jaccard(A,B) &= \frac{|A\cdot B|}{|max(A,B)|} = \frac{|A\cdot B|}{|A|+|B|-|A\cdot B|}\\ Accuracy(A,B) &= \frac{|A\cdot B|+|\overline{A} \cdot \overline{B}|}{|All|} \\ \end{align*} $$

Where $A,B$ binary vectors (with values of 1 for elements inside a group and 0 otherwise), one signify the ground truth and the other signify the classification result, and $All$ is just all elements considerred (a binary vector of 1's of the same length). For example, $ |A \cdot B|$ (inner product of $A$ and $B$) is the number of true positives, $ |\overline{A} \cdot \overline{B}|$ (inner product of the complement of $A$ and the complement of $B$) is the number of true negatives.

The Dice coefficient and Jaccard index are monotonically related, and the Tversky index generalizes them both, to read more about it see F-scores, Dice, and Jaccard set similarity.

The Dice coefficient is also the harmonic mean of Sensitivity and Precision, to see why it makes sense, read Why is the F-Measure a harmonic mean and not an arithmetic mean of the Precision and Recall measures?.

To read more about many of the terms in this answer and their relationships, see Evaluation of binary classifiers.

$\endgroup$
0
$\begingroup$

The Dice coefficient (also known as the Sørensen–Dice coefficient and F1 score) is defined as two times the area of the intersection of A and B, divided by the sum of the areas of A and B: Dice = 2 |A∩B| / (|A|+|B|) = 2 TP / (2 TP + FP + FN) (TP=True Positives, FP=False Positives, FN=False Negatives) Dice score is a performance metric for image segmentation problems. This is different from accuracy where the objective is to match the values, unlike dice which matches the value + position.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.