Skip to content

Reject a model whose class codes would be scored against label names - #9

Merged
Akram Zaytar (Akramz) merged 1 commit into
mainfrom
reject-coded-classes
Oct 31, 2026
Merged

Akram Zaytar (Akramz) merged 1 commit into
mainfrom
reject-coded-classes

Conversation

@Akramz

Copy link
Copy Markdown
Collaborator

Release-blocking: the only silently wrong number found in a pre-release user study.

Bug. model= with classes_ = [0, 1] (e.g. trained on is_crop) audited against string labels crop/noncrop: _as_model accepted the codes as positions in the sorted labels, so crop was read as class 0 (= non-crop in the model). Repro: a logistic regression with true test accuracy 0.993 printed test set (as reported) 0.01, PPI 0.01, no error. The README says the class order is checked when the model has classes_.

Fix. Codes 0..k-1 stand for the labels only when the labels are numbers; otherwise raise and ask for a model fitted on the label names. A function f(X) (no classes_) still takes sorted-label order. 5 added lines in pappi/core/pipeline.py::_as_model.

Review: the new condition in _as_model. Behaviour change: a model fitted on label-encoded codes against string labels now errors instead of being accepted.

Verified: repro now raises model classes ['0', '1'] are codes but the labels are names ['crop', 'noncrop']; fit the model on the label names; CI-equivalent env (requirements.txt): 9 passed, ruff clean; quickstart unchanged (0.69 vs truth 0.66). No new test added.

🤖 Generated with Claude Code

A model fitted on 0/1 (e.g. is_crop) audited against labels "crop"/"noncrop"
had its codes taken as positions in the sorted names, so crop was read as
class 0 and the model was scored with its classes swapped (accuracy 0.99
printed as 0.01, no error). Codes now stand for labels only when the labels
are numbers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Akramz
Akram Zaytar (Akramz) merged commit 0ea3e0e into main Oct 31, 2026
5 checks passed
@Akramz
Akram Zaytar (Akramz) deleted the reject-coded-classes branch October 31, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant