NumPy allowed · plain Python earns 10 bonus points
Compute the Jaccard overlap index between two bounding boxes for object detection evaluation and non-maximum suppression.
Implement iou_bounding_box(box_a, box_b): given two boxes formatted as [x1, y1, x2, y2] (with x1 <= x2 and y1 <= y2), compute the intersection rectangle coordinates: xA = max(x1_a, x1_b), yA = max(y1_a, y1_b), xB = min(x2_a, x2_b), yB = min(y2_a, y2_b). If xB <= xA or yB <= yA, the intersection area is 0.0. Otherwise inter = (xB - xA) * (yB - yA). The union is area_a + area_b - inter. Return inter / union rounded to 4 decimal places.
iou_bounding_box(box_a: list[float], box_b: list[float]) -> float