Skip to content

Changes caused by upgrading scikit-learn from 1.8.0 to 1.9.0 #534

Description

@martinholmer

After examining the scikit-learn code changes involved in moving from version 1.8.0 to version 1.9.0, and determining how the TMD code uses the scikit-learn package, Claude Code said this about why the TMD files differ when upgrading scikit-learn from 1.8.0 to 1.9.0:

⏺ Root cause is now fully mapped, with proof. The _splitter.pyx/_criterion.pyx
were substantially rewritten in 1.9.0 (criterion 1876→1656 lines; the
best-split loop restructured from while p < end_non_missing to while p < end
with missing-value handling pushed into the partitioner). That refactor — from
the missing-value-support work (#32119/#27630) — reorders criterion
evaluations and changes tie-breaking, which is why a weighted tree diverges
while an unweighted one stays identical.

Direct answer: exact reproduction [of 1.8.0 TMD files] under 1.9.0
is not achievable by a [TMD] code change.

Your pencon path is hit by two independent 1.9.0 changes, and only one is
reversible from your code:

#: 1
Change: Bootstrap: max_samples float now scales Σsample_weight (not n); draw
is
weight-proportional
Where: ensemble/_forest.py (PR #31529)
Revertible in your code?: Yes — take over the bootstrap
────────────────────────────────────────
#: 2
Change: Best-split search / criterion rewrite changes weighted-tree
tie-breaking
Where: compiled tree/_splitter.pyx, _criterion.pyx (#32119/#27630)
Revertible in your code?: No — no public knob; it's inside Cython

I verified #2 in isolation: a bare DecisionTreeRegressor(random_state=fixed),
no NaN, squared_error —

  • sample_weight=ones → byte-identical across versions (0ff45d…)
  • sample_weight=large → differs (1.8.0: 6749 nodes 6803bd…; 1.9.0: 6743 nodes
    8433f9…)

Because pencon fits trees with survey weights, #2 always bites. I confirmed
end-to-end on the real Imputation class: even with a byte-perfect bootstrap
reimplementation, fixed@1.9 (c4a313…) ≠ fixed@1.8 (25054f…). So no [TMD] code
change makes 1.9.0 reproduce 1.8.0 pencon values exactly.

What you should actually do

Option A — keep the scikit-learn==1.8.0 pin (recommended). This is exactly
what [TMD] commit 50c6315 did, and it's the only way to guarantee identical
pencon_* (and the downstream auto_loan_interest) values. Zero code change;
you're not missing a fix.

Option B — adopt 1.9.0 and re-baseline the fingerprints. #31529 was a
statistical-correctness fix and the splitter rewrite is part of 1.9's "better
numerics," so the new results are arguably more correct. Regenerate
tests/fingerprints/tmd_file_fingerprint.json under 1.9.0 and accept the
changed pencon_*/auto_loan_interest values.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions