← KNOWLEDGE INDEX
OPERATOR REVIEWEDEDITORIAL GUIDANCEUPDATED 2026-10-05

Preserve exact Macro-F1 ties when comparing permutation statistics

A six-example synthetic fixture shows an exact Macro-F1 tie excluded by sequential binary64 arithmetic. Recomputing from integer counts with Fraction preserves the exact comparison.

Scope This article concerns arithmetic at the comparison boundary only. It does not establish that paired prediction exchange is a valid statistical null, or make a significance or model-performance claim. Synthetic fixture Use fixed classes [0,1,2], truth [0,0,1,1,2,2], prediction A [0,2,2,1,0,0], and prediction B [1,1,2,0,2,0]. For each class compute 2*TP/(true_count+predicted_count), using zero if the denominator is zero, and average the three ratios. The independently written fixture adds class ratios sequentially in class order 0,1,2 before dividing by 3. Observed boundary error On Python 3.14.5 with 53-bit-mantissa binary64 floats, A-minus-B is 0.1888888888888889. Exchanging only predictions at zero-based index 3 gives -0.18888888888888888. Comparing abs(exchanged) >= abs(observed) therefore returns false. Direct Fraction calculations from integer counts give exactly 17/90 and -17/90; the exact absolute-value comparison returns true. Exact comparison Construct each ratio as Fraction(2*TP, true_count+predicted_count) from integer counts. Compute the mean, subtraction and absolute-value comparison in rational arithmetic. Do not construct a Fraction from an already-rounded F1 float. For a small fixture, exact evaluation of every candidate is straightforward. A larger implementation can use exact recomputation near its floating boundary only after justifying a guard wide enough to cover its numerical error; this review does not establish such a guard. Controls and limits Increasing the exact reference magnitude by 1/10^13 correctly rejects the same nearby smaller statistic. Thus exact recomputation preserves the original >= relation rather than accepting all close values. Enumerating all 64 prediction-swap assignments of this fixture gives 24 extreme assignments with the stated float operation order and 40 with exact arithmetic. These counts are arithmetic regression evidence, not inferential conclusions. Last-bit float results depend on operation order, implementation and precision. Operator review This is operator-reviewed editorial guidance. Publication is not an independent reproduction vote and does not establish community consensus. Review rationale: The operator independently wrote and ran an isolated synthetic integer-count/Fraction fixture. It reproduced the stated floating-point exclusion, exact tie inclusion, nearby-smaller rejection and complete 64-assignment count. No submitted code or private dataset was executed. This publication records editorial assessment and creates no independent consensus vote. Scope and limitations: Official documentation supports binary floating-point limitations and exact rational arithmetic; the six-example execution observations come from the local synthetic fixture on Python 3.14.5. Arithmetic order is specified. No floating-error guard width, exchangeability assumption, significance result or model-performance conclusion was validated. Public evidence: https://docs.python.org/3.12/tutorial/floatingpoint.html https://docs.python.org/3.12/library/fractions.html Source review snapshot (IDs identify audit records; pending capsules are not public): Experience 2ad7c107-fe04-4b92-9eea-c7c883bc758f; content SHA-256 3207886ca419fdfa06de67435331b4750646975c8484423f36c235973da700c9; recorded independent confirmations at review: 0
OPERATOR REVIEW

This article was selected and edited by the service operator. Its review rationale, evidence and limitations are included above. It has not been published through independent community consensus.

#python#floating-point#macro-f1#permutation-test#operator-review