skillfed

sklearn-compat

Ease support for compatible scikit-learn estimators across versions

sklearn-compat v0.1.6 2.4M downloads/30d#3,112 on PyPI13
Permissive license Active released

What it is and what it does

sklearn-compat is a small utility package that centralizes backward-compatible wrappers for scikit-learn's private developer APIs. It solves a specific problem for maintainers of scikit-learn-compatible third-party libraries: each time scikit-learn makes breaking changes to its internal utilities, those libraries have historically duplicated the same compatibility code. This package factors out those utilities into a single maintained source.

The package tracks scikit-learn's breaking changes across versions (currently supporting 1.2 and later) and provides stable import paths for functions that have moved, changed signatures, or been renamed. Developers can import from sklearn-compat instead of directly from scikit-learn's private modules, and the package handles version detection and fallbacks automatically.

Use it for:

  • Maintain a scikit-learn-compatible estimator library that needs to support multiple scikit-learn versions without duplicating compatibility shims.
  • Migrate code from scikit-learn 1.6+ where validate_data moved and force_all_finite was deprecated while keeping backward compatibility.
  • Use DataFrame type-checking utilities consistently across scikit-learn versions where they were added at different times.
  • Adapt test helpers like _convert_container that changed parameter names between scikit-learn versions without forking test code.
  • Support multiple scikit-learn versions in a library without vendoring or maintaining your own compatibility layer.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides backward-compatible wrappers for scikit-learn private utilities across multiple versions, allowing third-party libraries to support scikit-learn >= 1.2 without duplicating compatibility code.

Yes, if you maintain a scikit-learn-compatible library. It eliminates duplicate compatibility code across projects and is actively maintained to track scikit-learn changes. For end users of scikit-learn itself, there is no direct benefit—install only if a dependency requires it.

Install

sklearn-compat on PyPI

pip

pip install sklearn-compat

uv

uv add sklearn-compat

poetry

poetry add sklearn-compat

Installing sklearn-compat

Before you install

Low install friction with a single runtime dependency on scikit-learn. Active maintenance with a release 68 days ago and ongoing development.

License in practice

Permissive license allows use in both open-source and commercial projects without significant restrictions.

Quickstart

pip install sklearn-compat

from sklearn_compat.utils._dataframe import is_pandas_df
from sklearn_compat.utils.validation import validate_data

is_pandas_df(X)
X_validated = validate_data(estimator, X=X, ensure_all_finite=True)

Requires scikit-learn >= 1.2 to be installed; designed for library developers writing estimators, not end users.

Verify before relying

  • Whether the package will continue tracking all future scikit-learn breaking changes beyond current releases
  • Whether vendoring the package is recommended over the PyPI dependency for production use

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — scikit-learn
Maintenance actively maintained — 68 days since the last release
Last repo commit
First released
Downloads 2,353,710/month — #3,112 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: sklearn_compat-0.1.6-py3-none-any.whl

Development Status :: 4 - BetaLicense :: OSI Approved :: BSD LicenseProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Physics

Tags

scikit-learn version compatibilitysklearn private API wrappermulti-version sklearn supportsklearn estimator compatibilitycross-version sklearn utilities
sklearn-compatibleversion-compatibility

More Physics packages