Skip to main content

PyPI - Version Linux Windows/Macos Code style: black

Introduction

sklearn-onnx converts scikit-learn models to ONNX. Once in the ONNX format, you can use tools like ONNX Runtime for high performance scoring. All converters are tested with onnxruntime. Any external converter can be registered to convert scikit-learn pipeline including models or transformers coming from external libraries.

Documentation

Full documentation including tutorials is available at https://onnx.ai/sklearn-onnx/. Supported scikit-learn Models Last supported opset is 21.

You may also find answers in existing issues or submit a new one.

Installation

You can install from PyPi:

pip install skl2onnx

Or you can install from the source with the latest changes.

pip install git+https://github.com/onnx/sklearn-onnx.git

Getting started

# Train a model.
import numpy as np
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier

iris = load_iris()
X, y = iris.data, iris.target
X = X.astype(np.float32)
X_train, X_test, y_train, y_test = train_test_split(X, y)
clr = RandomForestClassifier()
clr.fit(X_train, y_train)

# Convert into ONNX format.
from skl2onnx import to_onnx

onx = to_onnx(clr, X[:1])
with open("rf_iris.onnx", "wb") as f:
    f.write(onx.SerializeToString())

# Compute the prediction with onnxruntime.
import onnxruntime as rt

sess = rt.InferenceSession("rf_iris.onnx", providers=["CPUExecutionProvider"])
input_name = sess.get_inputs()[0].name
label_name = sess.get_outputs()[0].name
pred_onx = sess.run([label_name], {input_name: X_test.astype(np.float32)})[0]

Contribute

We welcome contributions in the form of feedback, ideas, or code.

PR

Before you submit any PR, you should apply the following command lines to fix the style issues.

black .
ruff check .

License

Apache License v2.0

Release files for skl2onnx 1.20.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for skl2onnx 1.20.0
File Size Uploaded
skl2onnx-1.20.0.tar.gz 956.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for skl2onnx 1.20.0
File Interpreter ABI Platform
skl2onnx-1.20.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.3 MB

Release files / skl2onnx-1.20.0.tar.gz

Download URL skl2onnx-1.20.0.tar.gz
Size 956.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c74ea827d92ba186fe659695e8fc989cd97bfc320edce3d32b9936a5878da10a
BLAKE2b-256 checksum
How to use checksums
cb39a5015fefb613d5172541740540851a301c53392b57051cf4d313cb6d5718
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 30, 2026.

Transparency log

Release files / skl2onnx-1.20.0-py3-none-any.whl

Download URL skl2onnx-1.20.0-py3-none-any.whl
Size 317.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30cac34803d1776c14b336ae945e48ef28debfc339215acde1cc04b963ed3f7b
BLAKE2b-256 checksum
How to use checksums
24d3b0db77025a4683ec1b9aafc301b78c7e2e2059a1e2543e918435f3d03582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.20.0 This release

2 release files

1.19.1

2 release files

1.19.0

2 release files

1.18.0

2 release files

1.17.0

2 release files

1.16.0

2 release files

1.13

2 release files

1.12

2 release files

1.11.2

1 release file

1.11.1

1 release file

1.11

2 release files

1.10.4

2 release files

1.10.3

2 release files

1.10.2

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.0

1 release file

1.7.0

1 release file

1.6.1

2 release files

1.6.0

1 release file

1.5.2

1 release file

1.5.1

1 release file

1.5.0

1 release file

1.4.9

1 release file

1.4.8

1 release file

1.4.7

1 release file

1.4.6

1 release file

1.4.5

1 release file

1.4.4.2

1 release file

1.4.4.1

1 release file

1.4.4

1 release file

1.4.3

1 release file

1.4.2

1 release file

1.4.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page