This comparison crowns model B — but look at the thresholds: A was evaluated at 0.95 (flagging almost nothing) while B got 0.40 (flagging almost everything). Model A actually ranks the positives perfectly. Fix the comparison to evaluate both models at the SAME operating point, 0.5.
The break is on lines 12, 13 — but read the whole snippet first.