sklearn2pmml
Python library for converting Scikit-Learn pipelines to PMML
What it is and what it does
sklearn2pmml is a Python wrapper around the JPMML-SkLearn Java library that converts trained estimators and pipelines into PMML, an XML-based standard for representing machine learning models. It works with native estimators as-is, and also provides a PMMLPipeline class that captures feature metadata, enables prediction post-processing, embeds verification data, and allows fine-grained PMML customization. The package includes a command-line interface and a library API, plus additional transformer and predictor classes for domain specification, feature engineering, and model combination.
The main use case is exporting trained models from Python for deployment in other systems that consume PMML. It handles pickling safely using a custom Java component rather than Python's built-in unpickler, making it suitable for untrusted pickle files. Runtime dependencies are standard (scikit-learn, pandas, joblib, dill), but Java 11 or newer must be present on the system.
Use it for:
- Export a trained estimator to PMML for deployment in a non-Python scoring engine or business rules platform.
- Preserve feature names and metadata in PMML when working with older scikit-learn versions that lack feature tracking.
- Add prediction post-processing, verification data, and custom PMML edits to a pipeline before export using PMMLPipeline.
- Convert pickled estimators from disk to PMML via the command-line interface without writing Python code.
- Safely deserialize untrusted pickle files using sklearn2pmml's Java-based unpickler instead of Python's native pickle module.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts fitted Scikit-Learn pipelines to PMML (Predictive Model Markup Language) for deployment in other environments, supporting a wide range of estimators and transformers.
Yes, with conditions. Install if you need to export scikit-learn models to PMML for deployment outside Python and can accept the AGPL license terms. The package is actively maintained, has low install friction, and carries no known vulnerabilities. Do not install if your project is proprietary or closed-source without explicit AGPL compliance, or if Java 11 or newer is not available on your deployment system.
Install
sklearn2pmml on PyPI
pip
pip install sklearn2pmmluv
uv add sklearn2pmmlpoetry
poetry add sklearn2pmmlInstalling sklearn2pmml
Before you install
Low friction: pure Python wheel with four common runtime dependencies (dill, joblib, pandas, scikit-learn). Requires Java 11 or newer on the system path; this is the only non-Python prerequisite. Package is actively maintained with a recent release.
License in practice
Licensed under GNU Affero General Public License (AGPL) version 3.0. Use is restricted to projects that can comply with copyleft obligations—derivative works and distributed modifications must be released under the same license. Not suitable for proprietary or closed-source applications without explicit permission.
Quickstart
pip install sklearn2pmml
from sklearn2pmml import sklearn2pmml
import joblib
estimator = joblib.load("model.pkl")
sklearn2pmml(estimator, "model.pmml")
Java 11 or newer must be installed and available on the system PATH.
Verify before relying
- Whether all scikit-learn versions from 0.17 onward are truly compatible with a single package version.
- Performance overhead of Java-based pickle deserialization versus native Python unpickler for large models.
- Scope and completeness of supported estimator classes beyond the reference to JPMML-SkLearn features.
Package facts
| License | GNU Affero General Public License (AGPL) version 3.0 (agpl) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — dill, joblib, pandas, scikit-learn |
| Maintenance | actively maintained — 45 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 452,877/month — #6,579 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sklearn2pmml-0.132.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
azureml-train-coreProvides estimator classes for training machine…
unclear · top 15,000 on PyPI
onnxmltoolsConverts machine learning models from multiple…
permissive · top 5,000 on PyPI
mleapSerializes and deserializes machine learning…
permissive · top 5,000 on PyPI
sklearndfWraps scikit-learn estimators to return pandas…
permissive · top 15,000 on PyPI
fair-esmProvides pre-trained transformer protein…
permissive · top 15,000 on PyPI
sklearn-compatProvides backward-compatible wrappers for…
permissive · top 5,000 on PyPI
skopsSkops provides secure persistence and model…
unclear · top 5,000 on PyPI
spark-sklearnDistributes scikit-learn model training and…
permissive · top 15,000 on PyPI
azureml-pipelineBuilds, optimizes, and manages machine learning…
unclear · top 15,000 on PyPI
dask-mlDask-ML provides distributed and parallel…
permissive · top 15,000 on PyPI