Loading problem...
The Binary Overlap Coefficient, also known as the Sørensen-Dice similarity index, is a fundamental metric used to quantify the degree of agreement between two binary classification results. This coefficient is particularly prevalent in computer vision, medical imaging, and any domain where measuring the spatial or categorical overlap between predictions and ground truth is essential.
Given two binary arrays—one representing the actual (ground truth) labels and another representing the predicted labels—the Binary Overlap Coefficient measures the harmonic mean of their precision and recall characteristics. The formula for computing this coefficient is:
$$\text{Overlap Coefficient} = \frac{2 \times |A \cap P|}{|A| + |P|}$$
Where:
The coefficient produces a value in the range [0, 1]:
This metric is particularly attractive because:
When both arrays contain no positive instances (all zeros), the coefficient is typically defined as 0.0 to handle the mathematical edge case of division by zero in a semantically meaningful way.
Implement a function that computes the Binary Overlap Coefficient between two binary label arrays. The function should:
actual_labels = [1, 1, 0, 1, 0, 1]
predicted_labels = [1, 1, 0, 0, 0, 1]0.857Let's analyze the overlap:
• Actual positives (1s): positions 0, 1, 3, 5 → count = 4 • Predicted positives (1s): positions 0, 1, 5 → count = 3 • Intersection (both 1): positions 0, 1, 5 → count = 3
Applying the formula: Overlap Coefficient = (2 × 3) / (4 + 3) = 6 / 7 ≈ 0.857
This indicates approximately 85.7% overlap between predictions and ground truth.
actual_labels = [1, 0, 1, 0, 1]
predicted_labels = [1, 0, 1, 0, 1]1.0This represents perfect prediction:
• Actual positives: positions 0, 2, 4 → count = 3 • Predicted positives: positions 0, 2, 4 → count = 3 • Intersection: positions 0, 2, 4 → count = 3
Applying the formula: Overlap Coefficient = (2 × 3) / (3 + 3) = 6 / 6 = 1.0
A perfect score of 1.0 indicates complete agreement between actual and predicted labels.
actual_labels = [1, 1, 0, 0]
predicted_labels = [0, 0, 1, 1]0.0This represents complete disagreement:
• Actual positives: positions 0, 1 → count = 2 • Predicted positives: positions 2, 3 → count = 2 • Intersection: none → count = 0
Applying the formula: Overlap Coefficient = (2 × 0) / (2 + 2) = 0 / 4 = 0.0
A score of 0.0 indicates that the predictions and actual labels have absolutely no overlap—the model correctly predicted nothing.
Constraints