Skip to main content

EBM model serialization to ONNX

Project description

https://img.shields.io/pypi/v/ebm2onnx.svg CI Code Coverage Documentation Status https://mybinder.org/badge_logo.svg

Ebm2onnx converts EBM models to ONNX. It allows to run an EBM model on any ONNX compliant runtime.

Features

  • Binary classification

  • Regression

  • Continuous, nominal, and ordinal variables

  • N-way interactions

  • Multi-class classification (support is still experimental in EBM)

  • Expose predictions probabilities

  • Expose local explanations

  • Export a model as part of a scikit-learn pipeline (experimental)

The export of the models is tested against ONNX Runtime.

Get Started

Train an EBM model:

# prepare dataset
df = pd.read_csv('titanic_train.csv')
df = df.dropna()

feature_columns = ['Age', 'Fare', 'Pclass', 'Embarked']
label_column = "Survived"
y = df[[label_column]]
le = LabelEncoder()
y_enc = le.fit_transform(y)
x = df[feature_columns]
x_train, x_test, y_train, y_test = train_test_split(x, y_enc)

# train an EBM model
model = ExplainableBoostingClassifier(
    feature_types=['continuous', 'continuous', 'continuous', 'nominal'],
)
model.fit(x_train, y_train)

Then you can convert it to ONNX in a single function call:

import onnx
import ebm2onnx

onnx_model = ebm2onnx.to_onnx(
    model,
    ebm2onnx.get_dtype_from_pandas(x_train),
)
onnx.save_model(onnx_model, 'ebm_model.onnx')

If your dataset is not a pandas dataframe, you can provide the features’ types directly:

import ebm2onnx

onnx_model = ebm2onnx.to_onnx(
    model,
    dtype={
        'Age': 'double',
        'Fare': 'double',
        'Pclass': 'int',
        'Embarked': 'str',
    }
)
onnx.save_model(onnx_model, 'ebm_model.onnx')

Try it live

Supporting organizations

The following organizations are supporting Ebm2onnx:

  • SoftAtHome: Main supporter of Ebm2onnx development.

  • InterpretML: Ebm2onnx is hosted under the umbrella of the InterpretML organization.

img_sah img_interpret

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ebm2onnx-3.3.0.tar.gz (20.0 kB view details)

Uploaded Source

File details

Details for the file ebm2onnx-3.3.0.tar.gz.

File metadata

  • Download URL: ebm2onnx-3.3.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for ebm2onnx-3.3.0.tar.gz
Algorithm Hash digest
SHA256 bc3ed52f49a2ccc9a0f8e39a03315aa7b55773f22c9dd724bdcbf7cc38618a27
MD5 bab8d25198f7e0a2f4eed67fa38bcaa5
BLAKE2b-256 74ed1a0e19a0a92ff948927f111aa584597d86c4a912360664c9d6f347016a9e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page