Support scikit-learn 1.6+ by replacing removed private APIs#73
Open
mo-arvan wants to merge 1 commit intoLabo-Lacourse:masterfrom
Open
Support scikit-learn 1.6+ by replacing removed private APIs#73mo-arvan wants to merge 1 commit intoLabo-Lacourse:masterfrom
mo-arvan wants to merge 1 commit intoLabo-Lacourse:masterfrom
Conversation
Author
|
Hi, thank you for maintaining stepmix. I'm a researcher who needs stepmix on an environment running scikit-learn 1.6+, and the upper version bound is currently preventing installation. I focused on keeping the changes minimal to make the review straightforward. I've tested locally against scikit-learn 1.5.0, 1.6.1, and 1.8.0 on Python 3.12, and against Python 3.13 and 3.14 with scikit-learn 1.8.0. All tests pass in every configuration. I would appreciate it if you could take a look when you have a chance. Happy to make any changes if you have concerns or suggestions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #71
Removes the scikit-learn <=1.5.0 upper bound by replacing the two private APIs that broke in newer versions:
self._validate_data() (removed in sklearn 1.7) → public validate_data() via feature-detection compat layer
force_all_finite parameter (removed in sklearn 1.8) → ensure_all_finite via feature-detection compat layer
Also fixes BaseEstimator import to use the public sklearn.base path instead of sklearn.mixture._base.
What does NOT change
The private Gaussian mixture internals (_estimate_gaussian_parameters, _compute_precision_cholesky, GaussianMixture._initialize, etc.) are all forward-compatible through sklearn 1.8 — no changes needed.
Changes
stepmix/_compat.py (new) — feature-detection for validate_data and ensure_all_finite
stepmix/stepmix.py — replace removed APIs, add y= alias to score() and predict() to match fit() and pass sklearn estimator compliance checks
pyproject.toml — remove sklearn upper bound
.github/workflows/pytest.yaml — add Python 3.11–3.13 and sklearn 1.5/1.6/1.8 to CI matrix
Test results
All tests pass across sklearn 1.5.0, 1.6.1, and 1.8.0 on Python 3.12, and on Python 3.13/3.14 with sklearn 1.8.0.