FAILURE MAP
← Case archive

FA-6291 / Statistics / Open access

Jaccard set similarity · case 01

Adding input lengths double-counts the intersection and duplicates.

Verified by executionVariant 1 · 4 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Adding input lengths double-counts the intersection and duplicates.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return str(Fraction(len(set(a)&set(b)),len(set(a)|set(b)))) if a or b else "1"

Unsuccessful approach: The overlap coefficient ignores elements outside the smaller set.

Case contract

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Duplicates do not affect either set. Two empty sets have similarity one; exactly one empty set has zero. Exact operational definition: str(Fraction(len(set(a)&set(b)),len(set(a)|set(b)))) if a or b else "1"

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Statistical estimators results depend on the stated convention.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b):
    return str(Fraction(len(set(a)&set(b)),len(a)+len(b))) if a or b else "1"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2], [2, 3])', solve(*([1, 2], [2, 3])), '1/3')
check('fixture 2: ([1, 1], [1])', solve(*([1, 1], [1])), '1')
check('fixture 3: ([], [])', solve(*([], [])), '1')
check('fixture 4: ([1], [])', solve(*([1], [])), '0')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: ([1, 2], [2, 3])1/41/3Failed
fixture 2: ([1, 1], [1])1/31Failed
fixture 3: ([], [])11Passed
fixture 4: ([1], [])00Passed

SHA-256 / a8ff40e9d0e59b79d1e3bf593d1c5353c18950c21c8e8c95f0d2c77a8aa61a81

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b):
    return str(Fraction(len(set(a)&set(b)),min(len(set(a)),len(set(b))))) if a and b else "1"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2], [2, 3])', solve(*([1, 2], [2, 3])), '1/3')
check('fixture 2: ([1, 1], [1])', solve(*([1, 1], [1])), '1')
check('fixture 3: ([], [])', solve(*([], [])), '1')
check('fixture 4: ([1], [])', solve(*([1], [])), '0')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: ([1, 2], [2, 3])1/21/3Failed
fixture 2: ([1, 1], [1])11Passed
fixture 3: ([], [])11Passed
fixture 4: ([1], [])10Failed

SHA-256 / 73260e74b0bd421db9102e4803fb8993096d679a563cfac743f42772084e232b

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b):
    return str(Fraction(len(set(a)&set(b)),len(set(a)|set(b)))) if a or b else "1"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2], [2, 3])', solve(*([1, 2], [2, 3])), '1/3')
check('fixture 2: ([1, 1], [1])', solve(*([1, 1], [1])), '1')
check('fixture 3: ([], [])', solve(*([], [])), '1')
check('fixture 4: ([1], [])', solve(*([1], [])), '0')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: ([1, 2], [2, 3])1/31/3Passed
fixture 2: ([1, 1], [1])11Passed
fixture 3: ([], [])11Passed
fixture 4: ([1], [])00Passed

SHA-256 / 1f6f3df3cee8e5a1f67a79cdb3da32759d847f3d0233366201f67f2c09e75edd

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:37:59.744165+00:00.

Case digest / 3689bde37e6439e9004be97774ca388aaa060edb53d145cd7e0aa89818ec3bed