Skip to content

Support scikit-learn 1.6+ by replacing removed private APIs#73

Open
mo-arvan wants to merge 1 commit intoLabo-Lacourse:masterfrom
mo-arvan:upgrade-sklearn-compat
Open

Support scikit-learn 1.6+ by replacing removed private APIs#73
mo-arvan wants to merge 1 commit intoLabo-Lacourse:masterfrom
mo-arvan:upgrade-sklearn-compat

Conversation

@mo-arvan
Copy link
Copy Markdown

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.

@mo-arvan
Copy link
Copy Markdown
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.

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.

Upgrade scikit-learn dependency

1 participant