Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
1 change: 0 additions & 1 deletion _doc/examples/plot_time_tree_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from xgboost import XGBClassifier
from lightgbm import LGBMClassifier
from onnxruntime import InferenceSession
from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611
from sklearn.ensemble import HistGradientBoostingClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
Expand Down
1 change: 0 additions & 1 deletion _doc/sphinxdoc/source/_exts/generate_automated_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from pandas import DataFrame, read_excel, read_csv, concat, Series
from sklearn.exceptions import ConvergenceWarning
from sklearn.utils._testing import ignore_warnings
from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611
from sklearn.ensemble import AdaBoostRegressor, HistGradientBoostingRegressor
from sklearn.gaussian_process import GaussianProcessClassifier
import sphinx
Expand Down
1 change: 0 additions & 1 deletion _doc/sphinxdoc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import alabaster
from pyquickhelper.helpgen.default_conf import set_sphinx_variables
from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611
try:
from mlprodict.onnx_conv import register_converters, register_rewritten_operators
except ImportError as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_model_label_encoder_int(self):
data = numpy.array([10, 3, 5, -34, 0], dtype=numpy.int64)
model.fit(data)
# opset=13, 14, ...
for op in sorted(set([9, 10, 11, 12, 13, 14, TARGET_OPSET])):
for op in sorted(set([9, 10, 11, 12, 13, 14, 15, TARGET_OPSET])):
if op > TARGET_OPSET:
continue
with self.subTest(opset=op):
Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut_npy/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, operator, inputs, outputs):

class container_dummy:
def __init__(self):
self.target_opset = 14
self.target_opset = 15


class TestWrappers(ExtTestCase):
Expand Down
4 changes: 2 additions & 2 deletions _unittests/ut_onnx_conv/test_onnx_conv_knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def onnx_test_knn_single_classreg(self, dtype, n_targets=1, debug=False,

if target_opset is None:
opsets = list(sorted(set([
9, 10, 11, 12, 13, 14, get_opset_number_from_onnx()]))) # opset=13, 14, ...
9, 10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()]))) # opset=13, 14, ...
else:
opsets = [target_opset]
for ops in opsets:
Expand Down Expand Up @@ -475,7 +475,7 @@ def test_onnx_test_knn_transform(self):
clr = NearestNeighbors(n_neighbors=3)
clr.fit(X_train)

for to in (10, 11, 12, 13, 14): # opset=13, 14, ...
for to in (10, 11, 12, 13, 14, 15): # opset=13, 14, ...
if to > get_opset_number_from_onnx():
break
try:
Expand Down
1 change: 0 additions & 1 deletion _unittests/ut_onnx_conv/test_skl2onnx_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
ExtraTreesClassifier, ExtraTreesRegressor
)
try:
from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611
from sklearn.ensemble import (
HistGradientBoostingClassifier,
HistGradientBoostingRegressor
Expand Down
4 changes: 2 additions & 2 deletions _unittests/ut_onnxrt/test_benchmark_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def test_benchmark_replay(self):
FileNotFoundError)
res = list(enumerate_validated_operator_opsets(
# opset=13, 14, ...
0, fLOG=None, models={"LogisticRegression"}, opset_min=14,
opset_max=14, benchmark=False, store_models=True, dump_all=True,
0, fLOG=None, models={"LogisticRegression"}, opset_min=15,
opset_max=15, benchmark=False, store_models=True, dump_all=True,
dump_folder=temp, filter_exp=lambda m, p: (
"64" not in p and "b-cl" in p and "dec" not in p)))
self.assertNotEmpty(res)
Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut_onnxrt/test_onnx_profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_profile_onnxruntime1(self):
del model_def.opset_import[:] # pylint: disable=E1101
op_set = model_def.opset_import.add() # pylint: disable=E1101
op_set.domain = ''
op_set.version = 14 # opset=13, 14, ...
op_set.version = 15 # opset=13, 14, ...

X = (numpy.random.randn(4, 2) * 100000).astype( # pylint: disable=E1101
numpy.float32)
Expand Down
17 changes: 9 additions & 8 deletions _unittests/ut_onnxrt/test_onnxrt_python_runtime_.py
Original file line number Diff line number Diff line change
Expand Up @@ -3204,7 +3204,7 @@ def test_onnxt_runtime_reduce_sum(self):
X = numpy.array([[2, 1], [0, 1]], dtype=float)

# opset=13, 14, ...
for opset in (10, 11, 12, 13, 14, get_opset_number_from_onnx()):
for opset in (10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()):
if onnx_opset_version() < opset:
continue
if opset < 13:
Expand Down Expand Up @@ -3314,7 +3314,7 @@ def test_onnxt_runtime_reduce_sum_noop(self):
X = numpy.array([], dtype=float).reshape((2, 0))

# opset=13, 14, ...
for opset in (13, 14, get_opset_number_from_onnx()):
for opset in (13, 14, 15, get_opset_number_from_onnx()):
if onnx_opset_version() < opset:
continue

Expand Down Expand Up @@ -3572,7 +3572,7 @@ def test_onnxt_runtime_slice(self):
@wraplog()
def test_onnxt_runtime_slice_step_none(self):
# opset=13, 14, ...
for opset in [13, 14, get_opset_number_from_onnx()]:
for opset in [13, 14, 15, get_opset_number_from_onnx()]:
if opset > get_opset_number_from_onnx():
continue
with self.subTest(opset=opset):
Expand All @@ -3593,7 +3593,7 @@ def test_onnxt_runtime_slice_step_none(self):
@wraplog()
def test_onnxt_runtime_split(self):
# opset=13, 14, ...
for opset in [10, 11, 12, 13, 14, get_opset_number_from_onnx()]:
for opset in [10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()]:
if opset > get_opset_number_from_onnx():
continue
with self.subTest(opset=opset):
Expand Down Expand Up @@ -3645,7 +3645,7 @@ def test_onnxt_runtime_sqrt(self):
@wraplog()
def test_onnxt_runtime_squeeze(self):
# opset=13, 14, ...
for opset in [10, 11, 12, 13, 14, get_opset_number_from_onnx()]:
for opset in [10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()]:
if opset > get_opset_number_from_onnx():
continue
with self.subTest(opset=opset):
Expand Down Expand Up @@ -3838,7 +3838,7 @@ def test_onnxt_runtime_transpose(self):
@wraplog()
def test_onnxt_runtime_unsqueeze(self):
# opset=13, 14, ...
for opset in [10, 11, 12, 13, 14, get_opset_number_from_onnx()]:
for opset in [10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()]:
if opset > get_opset_number_from_onnx():
continue
with self.subTest(opset=opset):
Expand Down Expand Up @@ -4187,7 +4187,8 @@ def test_make_constant(self):
(11, OnnxConstant_11),
(9, OnnxConstant_9)]

expected_type = {14: Constant_12, 12: Constant_12, 13: Constant_12,
expected_type = {15: Constant_12, 14: Constant_12,
12: Constant_12, 13: Constant_12,
11: Constant_11, 9: Constant_9}

if (not sys.platform.startswith('win') or
Expand Down Expand Up @@ -4227,7 +4228,7 @@ def test_make_constant(self):
self.assertEqualArray(exp, got['Ad_C0'])

def test_op_constant(self):
for opv in [9, 10, 11, 12, 13, 14]: # opset=13, 14, ...
for opv in [9, 10, 11, 12, 13, 14, 15]: # opset=13, 14, ...
for dtype in [numpy.float32, numpy.float64,
numpy.int32, numpy.int64]:
with self.subTest(opv=opv, dtype=dtype):
Expand Down
12 changes: 6 additions & 6 deletions _unittests/ut_onnxrt/test_onnxrt_python_runtime_control_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def expect(node, inputs, outputs, name):
del model_def.opset_import[:] # pylint: disable=E1101
op_set = model_def.opset_import.add() # pylint: disable=E1101
op_set.domain = ''
op_set.version = 14
model_def.ir_version = 7
op_set.version = 15
model_def.ir_version = 8

test_cases = {
'at_back': [numpy.array([10, 11, 12]).astype(numpy.int64)],
Expand Down Expand Up @@ -191,8 +191,8 @@ def test_loop(self):
del model_def.opset_import[:] # pylint: disable=E1101
op_set = model_def.opset_import.add() # pylint: disable=E1101
op_set.domain = ''
op_set.version = 14
model_def.ir_version = 7
op_set.version = 15
model_def.ir_version = 8

expected = numpy.array([
1., 1., 2., 1., 2., 3., 1., 2.,
Expand Down Expand Up @@ -307,8 +307,8 @@ def test_loop_additional_input(self):
del model_def.opset_import[:] # pylint: disable=E1101
op_set = model_def.opset_import.add() # pylint: disable=E1101
op_set.domain = ''
op_set.version = 14
model_def.ir_version = 7
op_set.version = 15
model_def.ir_version = 8

expected = numpy.array([
1., 1., 2., 1., 2., 3., 1., 2.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from sklearn.utils._testing import ignore_warnings
except ImportError:
from sklearn.utils.testing import ignore_warnings
from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611
from sklearn.ensemble import RandomForestRegressor, HistGradientBoostingRegressor
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import (
Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut_onnxrt/test_onnxrt_switch_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_onnxt_iris_gaussian_process_exp_sine_squared_13(self):
model_def = to_onnx(
clr, X_train.astype(numpy.float32),
options={GaussianProcessRegressor: {'return_std': True}},
target_opset=14) # opset=13, 14, ...
target_opset=15) # opset=13, 14, ...
oinf = OnnxInference(model_def, runtime='python')

res = oinf.run({'X': X_test.astype(numpy.float32)})
Expand Down
1 change: 0 additions & 1 deletion _unittests/ut_testing/test_skl2onnx_testing_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
try:
from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611
from sklearn.ensemble import HistGradientBoostingClassifier
except ImportError:
HistGradientBoostingClassifier = None
Expand Down
1 change: 0 additions & 1 deletion _unittests/ut_tools/test_model_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import inspect
import unittest
import numpy
from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression, LinearRegression
from sklearn.neighbors import KNeighborsClassifier
Expand Down
18 changes: 10 additions & 8 deletions _unittests/ut_tools/test_onnx_micro_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

class TestOnnxMicroRuntime(ExtTestCase):

opset = 15 # opset=13, 14, ...

def test_onnx_micro_runtime(self):
opset = 14 # opset=13, 14, ...
opset = TestOnnxMicroRuntime.opset
dtype = numpy.float32
x = numpy.array([1, 2, 4, 5, 5, 4]).astype(
numpy.float32).reshape((3, 2))
Expand All @@ -32,7 +34,7 @@ def test_onnx_micro_runtime_exc1(self):
self.assertRaise(lambda: OnnxMicroRuntime(None), TypeError)

def test_onnx_micro_runtime_exc2(self):
opset = 14 # opset=13, 14, ...
opset = TestOnnxMicroRuntime.opset
dtype = numpy.float32
x = numpy.array([1, 2, 4, 5, 5, 4]).astype(
numpy.float32).reshape((3, 2))
Expand All @@ -45,7 +47,7 @@ def test_onnx_micro_runtime_exc2(self):
self.assertRaise(lambda: rt.run(x), TypeError)

def test_onnx_micro_runtime_shape(self):
opset = 14 # opset=13, 14, ...
opset = TestOnnxMicroRuntime.opset
x = numpy.array([1, 2, 4, 5, 5, 4]).astype(
numpy.float32).reshape((3, 2))
cop = OnnxShape('X', op_version=opset, output_names=['Y'])
Expand All @@ -55,7 +57,7 @@ def test_onnx_micro_runtime_shape(self):
self.assertEqual(numpy.array(x.shape, dtype=numpy.int64), out['Y'])

def test_onnx_micro_runtime_transpose(self):
opset = 14 # opset=13, 14, ...
opset = TestOnnxMicroRuntime.opset
x = numpy.array([1, 2, 4, 5, 5, 4]).astype(
numpy.float32).reshape((3, 2))
cop = OnnxTranspose('X', perm=[1, 0], op_version=opset,
Expand All @@ -66,7 +68,7 @@ def test_onnx_micro_runtime_transpose(self):
self.assertEqual(x.T, out['Y'])

def test_onnx_micro_runtime_matmul(self):
opset = 14 # opset=13, 14, ...
opset = TestOnnxMicroRuntime.opset
x = numpy.array([1, 2, 4, 5]).astype(
numpy.float32).reshape((2, 2))
cop = OnnxMatMul('X', 'X', op_version=opset,
Expand All @@ -77,7 +79,7 @@ def test_onnx_micro_runtime_matmul(self):
self.assertEqual(numpy.matmul(x, x), out['Y'])

def test_onnx_micro_runtime_squeeze(self):
opset = 14 # opset=13, 14, ...
opset = TestOnnxMicroRuntime.opset
x = numpy.array([1, 2, 4, 5]).astype(
numpy.float32).reshape((2, 2, 1))
cop = OnnxSqueeze('X', numpy.array([2], dtype=numpy.int64),
Expand All @@ -88,7 +90,7 @@ def test_onnx_micro_runtime_squeeze(self):
self.assertEqual(numpy.squeeze(x), out['Y'])

def test_onnx_micro_runtime_unsqueeze(self):
opset = 14 # opset=13, 14, ...
opset = TestOnnxMicroRuntime.opset
x = numpy.array([1, 2, 4, 5]).astype(
numpy.float32).reshape((2, 2))
cop = OnnxUnsqueeze('X', numpy.array([2], dtype=numpy.int64),
Expand All @@ -99,7 +101,7 @@ def test_onnx_micro_runtime_unsqueeze(self):
self.assertEqual(x.reshape((2, 2, 1)), out['Y'])

def test_onnx_micro_runtime_gemm(self):
opset = 14 # opset=13, 14, ...
opset = TestOnnxMicroRuntime.opset
x = numpy.array([1, 2, 4, 5]).astype(
numpy.float32).reshape((2, 2))
for ta in [0, 1]:
Expand Down
4 changes: 3 additions & 1 deletion _unittests/ut_tools/test_ort.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

class TestOrt(ExtTestCase):

opset = 15 # opset = 13, 14, ...

def test_prepare_c_profiling(self):
opset = 14 # opset=13, 14, ...
opset = TestOrt.opset
dtype = numpy.float32
x = numpy.array([1, 2, 4, 5, 5, 4]).astype(
numpy.float32).reshape((3, 2))
Expand Down
31 changes: 21 additions & 10 deletions _unittests/ut_tools/test_sklearn_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ def test_statistics_rf(self):
res = inspect_sklearn_model(clr)
self.assertEqual(res['max_depth'], 4)
self.assertEqual(res['ntrees'], 10)
onx = to_onnx(clr, X_train[:1].astype(numpy.float32))
ostats = onnx_statistics(onx)
for k, v in {'nnodes': 11, 'doc_string': '', 'domain': 'ai.onnx', 'model_version': 0,
'producer_name': 'skl2onnx', 'ai.onnx.ml': 1}.items():
self.assertEqual(ostats[k], v)
for dtype in [numpy.float32, numpy.float64]:
with self.subTest(dtype=dtype):
onx = to_onnx(clr, X_train[:1].astype(dtype))
ostats = onnx_statistics(onx)
for k, v in {'nnodes': 1, 'doc_string': '',
'domain': 'ai.onnx', 'model_version': 0,
'producer_name': 'skl2onnx', 'ai.onnx.ml': 1}.items():
if k == 'ai.onnx.ml' and k not in ostats:
continue
self.assertEqual(ostats[k], v)

@ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning))
def test_statistics_adaboost(self):
Expand All @@ -99,11 +104,17 @@ def test_statistics_pipeline_rf(self):
self.assertEqual(res['max_depth'], 4)
self.assertEqual(res['ntrees'], 10)
self.assertEqual(res['nop'], 11)
onx = to_onnx(clr, X_train[:1].astype(numpy.float32))
ostats = onnx_statistics(onx)
for k, v in {'nnodes': 12, 'doc_string': '', 'domain': 'ai.onnx', 'model_version': 0,
'producer_name': 'skl2onnx', 'ai.onnx.ml': 1}.items():
self.assertEqual(ostats[k], v)
expected = {numpy.float32: 2, numpy.float64: 3}
for dtype in [numpy.float32, numpy.float64]:
with self.subTest(dtype=dtype):
onx = to_onnx(clr, X_train[:1].astype(dtype))
ostats = onnx_statistics(onx)
for k, v in {'nnodes': expected[dtype], 'doc_string': '',
'domain': 'ai.onnx', 'model_version': 0,
'producer_name': 'skl2onnx', 'ai.onnx.ml': 1}.items():
if k == 'ai.onnx.ml' and k not in ostats:
continue
self.assertEqual(ostats[k], v)

@ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning))
def test_statistics_lin(self):
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ jobs:
# export MACOSX_DEPLOYMENT_TARGET=10.13
python setup.py build_ext --inplace
displayName: 'Build package inplace'
- script: python -u setup.py unittests -g ".*((LONG)|(SKIP)|(notebooks)).*" -d 50
- script: python -u setup.py unittests -g ".*((LONG)|(SKIP)|(notebooks)|(asv_benchmark)|(test_onnx_helper)|(test_onnx_inference)|(test_onnxrt_python_runtime_ml)|(test_custom_embedded_any_models)|(test_custom_)|(test_onnx_pipeline)|(test_onnx_speedup_cluster)).*" -d 7
displayName: 'Runs Unit Tests'
- script: |
python -m pip install cibuildwheel
Expand Down
2 changes: 0 additions & 2 deletions mlprodict/asv_benchmark/_create_asv_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,6 @@ def _additional_imports(model_name):
"""
if model_name == 'IterativeImputer':
return ["from sklearn.experimental import enable_iterative_imputer # pylint: disable=W0611"]
if model_name in ('HistGradientBoostingClassifier', 'HistGradientBoostingClassifier'):
return ["from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611"]
return None


Expand Down
Loading