Skip to content

R20

What to build

ROC and calibration scores reflect declared class semantics regardless of label permutation.

Source and evidence

Repository scientific/architectural review, snapshot 86c8517, item R20. Classification: confirmed defect; high severity.

Binary ROC AUC selects probabilities for the declared positive_class but sends original string labels to sklearn. The dependency interprets scores as belonging to the greater label, so selecting the lesser label reverses the result. Calibration passes class-ordered columns through unchanged even when their declaration is not lexicographic. Sklearn's log-loss and Brier implementations interpret those columns in lexical order. The report retains finite scores and COMPLETE status despite incorrect class semantics. Revisions that hash declaration order do not fix its runtime interpretation.

The retained class-order probe uses installed sklearn 1.8.0, two balanced classes, and correct-class probability 0.9 on each case. With explicit supported average="macro", ROC AUC is 1 for positive yes but 0 for positive no; the pairwise ranking oracle is 1 for either declaration. Reversing both class order and columns leaves predictions identical but changes log loss from 0.10536051565782628 to 2.3025850929940455 and Brier from approximately 0.02 to 1.62. The independent oracles are -log(0.9) and (1-0.9)**2 + (0-0.1)**2. Sklearn emits ordering warnings for calibration, but the evaluator still publishes the wrong finite result. Existing tests change identity order without evaluating the reordered scorer.

These expectations follow the dependency's documented binary ROC score convention and log-loss column ordering. The numerical evidence above is from the installed 1.8.0 package, not an assumption that the current online version is installed locally.

Acceptance criteria

  • [ ] Perfect binary discrimination scores ROC AUC 1 for either declared positive class using an independent ranking oracle.
  • [ ] Reversing class declaration and matching probability columns preserves log loss and Brier scores.
  • [ ] Multiclass, reliability bins and weighted cases use one validated mapping and maintain stable identity semantics.
  • [ ] Tests include nonlexical string labels and independent -log(p) and Brier arithmetic, not only delegation to sklearn.
  • [ ] Preserve Consumer-owned meaning, payload-free evidence, disabled optional-import isolation, safe diagnostics and the non-relaxable Safety Floor.
  • [ ] Run the narrowest observable contract, then applicable committed Make gates. Record every command and outcome; update specifications/compatibility evidence for changed public or wire contracts. Run native Collector verification for changed Collector assets and build for packaging changes.

Design guidance

Encode target membership in the chosen positive class and remap columns consistently at the dependency boundary. Share one validated class-index mapping across ROC/calibration/reliability adapters while keeping optional imports lazy.

Keep prefactoring narrow and verifiable in this slice. Reuse established owners and structural interfaces; introduce a pattern only when it clarifies a real responsibility or variation point. Do not add consumer vocabulary or private payloads to platform code or evidence. Mocked/local results must not claim hosted, production, accelerator or release qualification.

Blocked by

None (can start immediately). Shared-area coordination is useful, but no other review fix is a genuine prerequisite for this slice.

Verification scope

Convert the described counterexample or investigation oracle into an observable test at the lowest suitable public boundary. Prefer bounded operation-count or deterministic interleaving evidence to flaky timing assertions; timing guarantees need a declared tolerance and independently owned cleanup. This ticket authorizes remediation/research, not publication or deployment.