Code Monkey home page Code Monkey logo

ebm2onnx's Introduction

Ebm2onnx

CI Code Coverage Documentation Status

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

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

ebm2onnx's People

Contributors

mainro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.