Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #150 (lightgbm converters), tests converted models with onnxruntime, moves lightgbm in a separate folder #144

Merged
merged 75 commits into from
Oct 30, 2018

Conversation

xadupre
Copy link
Collaborator

@xadupre xadupre commented Oct 8, 2018

The PR adds functions in the current series of unit tests to dump data, prédictions, models and converted models (pickle). Another test series retrieves all dumped files, unpickles them, runs the prediction with onnxruntime and compares the predictions against the expected outputs.

It is done only for one model. Adding more later if this design is approved.

@CLAassistant
Copy link

CLAassistant commented Oct 8, 2018

CLA assistant check
All committers have signed the CLA.

@xadupre xadupre changed the title test converted models with onnxruntime test converted models with onnxruntime, move lightgbm in a separate folder, fix lightgbm converter Oct 25, 2018
@xadupre xadupre changed the title test converted models with onnxruntime, move lightgbm in a separate folder, fix lightgbm converter Fixes #150 (lightgbm converters), tests converted models with onnxruntime, moves lightgbm in a separate folder Oct 25, 2018
@@ -80,6 +80,14 @@ def add_output(self, variable):
self._outputs.append(variable)


class SklearnModelContainer(CommonSklearnModelContainer):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no any difference between sklearn and lightbgm model containter, can we just rename SklearnModelContainer as SklearnAndLightGBMModelContainer or a better name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XGBoost will probably follow the same design, that's why I split. I chose CommonSklearnModelContainer because many frameworks follow sklearn API now.

def convert_lightgbm(model, name=None, initial_types=None, doc_string='', targeted_onnx=onnx.__version__,
custom_conversion_functions=None, custom_shape_calculators=None):
if not utils.sklearn_installed():
raise RuntimeError('scikit-learn is not installed. Please install lightgbm to use this feature.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still call it sklearn_installed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@@ -10,7 +10,7 @@
from collections import Counter
from lightgbm import LGBMClassifier, LGBMRegressor
from ...common._registration import register_converter
from .TreeEnsemble import _get_default_tree_classifier_attribute_pairs
from ...sklearn.operator_converters.TreeEnsemble import _get_default_tree_classifier_attribute_pairs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it in the common folder to avoid cross reference among converters.
And remove _ from the beginning of the function name.

@@ -1,7 +1,6 @@
dist: xenial
language: python
env:
- ONNX_VERSION="==1.1.2" ONNX_ML=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This backward combability is required. Is there any thing blocked this version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I just wanted to have faster CI. I'll add it back.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't seen it was added back yet, or do I miss something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just wanted to keep the test short:
python 3.5 - tests against onnx==1.2.3
python 3.6 - tests against onnx==1.3.0
python3.7 - test against onnx (latest version)

It is specified below in the file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean ONNX_VERSION == 1.1.2 need be tested as well since there is backward compatible requirement for this version.

@wenbingl wenbingl merged commit d66b74b into onnx:master Oct 30, 2018
wenbingl pushed a commit to wenbingl/onnxmltools that referenced this pull request Nov 14, 2018
…xruntime, moves lightgbm in a separate folder (onnx#144)

* remove unnecessary print, add quote around filenames in some places

* replaces as_matrix by values (pandas warnings)

* changes variable name to avoid getting warnings about invalid names

* better consistency for converted, allows targetted onnx version to be None

* Revert "better consistency for converted, allows targetted onnx version to be None"

This reverts commit e257ca1.

* handle the comparison of ONNX versions in only one place

* fix bug with OneHotEncoder and scikit-learn 0.20

* release the constraint on scikit-learn (0.20.0 allowed)

* fix one type issue for Python 2.7

* add documentation to compare_strict_version

* implements Keras conversion for mobilenet

* first unit test checking the onnx models produces the same outputs as the original model

* disable tests with onnxruntime on python 2.7 as onnxruntime is not available

* fix travis setup

* extends the list of models tested with a runtime

* fix travis.yml

* fix travis.yml

* switch to ubuntu 16.04

* do not store err, out on files (travis.yml)

* update travis

* Revert "Merge branch 'mobilenet' of https://github.com/xadupre/onnxmltools into testrt"

This reverts commit 35059d7, reversing
changes made to 2625051.

* skip unit test with relu6 if not available

* fix missing import

* update travis

* update travis

* disable one text runtime test

* show capture in travis

* show runtime status as warning

* fix warning message

* fix conversion for logisticregression and multiclass==2

* complete unit tests for linear models

* use conda to install tensorflow

* test linear regressors with onnxruntime

* fixes converters, test against onnxruntime

* disable two tests for the runtime

* documentation

* better handling of exceptions

* update error message

* update for Berunoulli and Multinomial

* disable runtime test for NaiveBayes, update OneHotEncoder with scikit-learn 0.22

* add test for pipeline

* Fix issue for python 2.7 (use of from for exception)

* add test for SVR, SVC

* add test for coremltools

* add first runtime test on keras

* fix missing import

* One test for model tested with the runtime

* fix misspelling

* Disable runtime test for version 0.1.3

* Fix misspelling

* Move lightgbm converters in a separate folders, fix lightgbm converters

* Refactoring, split unit test into multiple ones

* add function lightgbm_installed

* finalize refactoring about lightgbm

* refactor tests with keras

* add instructions to test a backend

* Fix import issue in coremltools

* Call onnxruntime in the same series process not in a second call.

* fixes travis build

* Enables complex conditions for test failure

* Fix python 2.7, disable one test not running with the current version of onnxmlruntime (but not the dev version)

* fix one function, enable disabled part

* checks that backend is enabled

* Disables unit test for some version of onnxruntime

* fixes for python 3.6 and onnx==1.2.1

* disable runtime test on onnx==1.2.1

* Update travis.yml with different onnx versions

* Update .travis.yml
@xadupre xadupre deleted the testrt branch February 14, 2019 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants