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 variables

  • Categorical variables

  • Interactions

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

  • Expose local explanations

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','categorical'],
)
model.fit(x_train, y_train)

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

import ebm2onnx

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

Try it live

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-1.1.1.tar.gz (9.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: ebm2onnx-1.1.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

File hashes

Hashes for ebm2onnx-1.1.1.tar.gz
Algorithm Hash digest
SHA256 aef6a4fe13a880a70cdba3dcaeb60b5c89ff844a0c0e715b102958da8bb2144c
MD5 09f757f74950e99fd8865a6453853aca
BLAKE2b-256 d0913ed1de1d731eb6ee7328098005144e56021dfbfed3598afd5891fbfc2061

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