Segmentation
Dice coefficient
Implemented
segmentation.diceDefinition
Overlap between predicted and ground-truth masks, weighting the intersection twice.
Formula
Dice = 2|A ∩ B| / (|A| + |B|)
Range: [0, 1]
Inputs and outputs
- y_true: ground-truth mask (H×W or N×H×W)
- y_pred: predicted mask with the same shape
Returns: float or per-class array
Assumptions
No assumptions beyond valid, aligned inputs of the documented types.
Limitations
- Undefined when both masks are empty; the `empty` policy (1.0, NaN, or exclude) is always explicit.
Python API
import evalsuite as es
es.dice(y_true, y_pred) # macro over classes
es.dice(y_true, y_pred, aggregate="image") # mean of per-image scoresReferences
- Dice, L. R. (1945). Measures of the amount of ecologic association between species. Ecology, 26(3), 297–302.