Introduction
proglearn-onnx converts ProgLearn 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.
Supported Converters
This version implements ProgLearn estimators that adhere to the sklearn-onnx API on registering custom converters
| Name | Package | Supported |
|---|---|---|
| ClassificationProgressiveLearner | progressive_learner | Yes |
| LifelongClassificationForest | forest | Yes |
| LifelongClassificationNetwork | network | No |
Installation
You can install from PyPi:
pip install prog2onnx
Note: There is a known backtracking issue in pip's dependency resolver that may significantly affect the time required to fetch the correct versions of the dependencies. A quick and easy fix is to add --use-deprecated legacy-resolver
at the end of pip install .
Getting started
# Train a model using 3 tasks.
import numpy as np
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from proglearn.forest import LifelongClassificationForest
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 = LifelongClassificationForest(default_n_estimators=10)
for _ in range(3):
clr.add_task(X_train, y_train)
# Convert into ONNX format.
from prog2onnx import Prog2ONNX
p2o = Prog2ONNX(clr)
# Convert for task_ID = 0
onx = p2o.to_onnx(0)
# Validate ONNX model (Optional)
p2o.validate()
# Save ONNX model to file (Optional)
p2o.save("forest_iris_0.onnx")
# Compute the prediction with onnxruntime.
import onnxruntime as rt
sess = rt.InferenceSession(onx.SerializeToString(), providers=["CPUExecutionProvider"])
input_name = sess.get_inputs()[0].name
pred_onx = sess.run(None, {input_name: X_test.astype(np.float32)})[0]
Testing
Several scenarios are assessed in the form of separate tests using the Python's built in unittest testing framework.
python -m unittest -v tests/test_proglearn.py
Contribute
We are open to contributions in the form of feedback, ideas, or code.
License
Metadata
Release files for prog2onnx 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prog2onnx-0.0.1-0beta-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Release files / prog2onnx-0.0.1-0beta-py2.py3-none-any.whl
| Download URL | prog2onnx-0.0.1-0beta-py2.py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a964cad7791cc65991f374baa814a74e2e5e7f492476821d0340799383b31490
|
|
BLAKE2b-256 checksum How to use checksums |
ffd7134c7a32dc09ecca16a9ba506dc085eb51cf6d9b5b2ecb6e75f043d52bc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|