Skip to content

Commit ba70ad6

Browse files
authored
Skl2onnx wrapper, deleting redundant converter code (#222)
* including dependency on skl2onnx for onnxmltools 1.4 * creating wrapper for scikitlearn to onnx model conversion * deleting sklearn converter files and tests to remove redundant code
1 parent 7380e62 commit ba70ad6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+15
-3309
lines changed

onnxmltools/convert/common/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ def sklearn_installed():
2020
except ImportError:
2121
return False
2222

23+
def skl2onnx_installed():
24+
"""
25+
Checks that *skl2onnx* converter is available.
26+
"""
27+
try:
28+
import skl2onnx
29+
return True
30+
except ImportError:
31+
return False
2332

2433
def coreml_installed():
2534
"""

onnxmltools/convert/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from ..proto import onnx
88
from .common import utils
99

10-
1110
def convert_coreml(model, name=None, initial_types=None, doc_string='', target_opset=None,
1211
targeted_onnx=onnx.__version__ , custom_conversion_functions=None, custom_shape_calculators=None):
1312
if not utils.coreml_installed():
@@ -55,6 +54,9 @@ def convert_sklearn(model, name=None, initial_types=None, doc_string='', target_
5554
if not utils.sklearn_installed():
5655
raise RuntimeError('scikit-learn is not installed. Please install scikit-learn to use this feature.')
5756

58-
from .sklearn.convert import convert
59-
return convert(model, name, initial_types, doc_string, target_opset, targeted_onnx,
57+
if not utils.skl2onnx_installed():
58+
raise RuntimeError('skl2onnx is not installed. Please install skl2onnx to use this feature.')
59+
60+
from skl2onnx.convert import convert_sklearn as convert_skl2onnx
61+
return convert_skl2onnx(model, name, initial_types, doc_string, target_opset,
6062
custom_conversion_functions, custom_shape_calculators)

onnxmltools/convert/sklearn/__init__.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

onnxmltools/convert/sklearn/_parse.py

Lines changed: 0 additions & 228 deletions
This file was deleted.

onnxmltools/convert/sklearn/convert.py

Lines changed: 0 additions & 98 deletions
This file was deleted.

onnxmltools/convert/sklearn/operator_converters/Binarizer.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)