This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_onnxrt_validate.py
64 lines (58 loc) · 2.53 KB
/
test_onnxrt_validate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
@brief test log(time=40s)
"""
import os
import unittest
from logging import getLogger
from pandas import DataFrame, read_csv
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import (
get_temp_folder, ExtTestCase, skipif_circleci, unittest_require_at_least
)
from sklearn.exceptions import ConvergenceWarning
from sklearn.utils.testing import ignore_warnings
import skl2onnx
from mlprodict.onnxrt.validate import enumerate_validated_operator_opsets, summary_report
class TestOnnxrtValidate(ExtTestCase):
@unittest_require_at_least(skl2onnx, '1.5.9999')
@skipif_circleci("too long")
@ignore_warnings(category=(UserWarning, ConvergenceWarning, RuntimeWarning))
def test_validate_sklearn_operators_all(self):
fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__")
logger = getLogger('skl2onnx')
logger.disabled = True
verbose = 1 if __name__ == "__main__" else 0
temp = get_temp_folder(__file__, "temp_validate_sklearn_operators_all")
if False: # pylint: disable=W0125
rows = list(enumerate_validated_operator_opsets(
verbose, models={"AdaBoostRegressor"}, opset_min=10,
debug=True, fLOG=fLOG))
else:
rows = list(enumerate_validated_operator_opsets(
verbose, debug=None, fLOG=fLOG, dump_folder=temp,
opset_min=10, time_kwargs={10: dict(number=2, repeat=2)},
n_features=[None]))
self.assertGreater(len(rows), 1)
df = DataFrame(rows)
self.assertGreater(df.shape[1], 1)
fLOG("output results")
df.to_csv(os.path.join(temp, "sklearn_opsets_report.csv"), index=False)
df.to_excel(os.path.join(
temp, "sklearn_opsets_report.xlsx"), index=False)
def test_validate_summary(self):
this = os.path.abspath(os.path.dirname(__file__))
data = os.path.join(this, "data", "sklearn_opsets_report.csv")
df = read_csv(data)
piv = summary_report(df)
self.assertGreater(piv.shape[0], 1)
self.assertGreater(piv.shape[1], 10)
self.assertIn('LogisticRegression', set(piv['name']))
temp = get_temp_folder(__file__, "temp_validate_summary")
fLOG("output results")
piv.to_csv(os.path.join(
temp, "sklearn_opsets_summary.csv"), index=False)
piv.to_excel(os.path.join(
temp, "sklearn_opsets_summary.xlsx"), index=False)
if __name__ == "__main__":
# TestOnnxrtValidate().test_n_features_int()
unittest.main()