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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
@brief test log(time=5s) | ||
""" | ||
import os | ||
import unittest | ||
import pickle | ||
from logging import getLogger | ||
from pandas import DataFrame | ||
from pyquickhelper.loghelper import fLOG | ||
from pyquickhelper.pycode import ( | ||
get_temp_folder, ExtTestCase, skipif_circleci, unittest_require_at_least | ||
) | ||
from sklearn.exceptions import ConvergenceWarning | ||
try: | ||
from sklearn.utils._testing import ignore_warnings | ||
except ImportError: | ||
from sklearn.utils.testing import ignore_warnings | ||
import skl2onnx | ||
from mlprodict.onnxrt.validate import enumerate_validated_operator_opsets | ||
|
||
|
||
class TestOnnxrtValidateDumpAll(ExtTestCase): | ||
|
||
@unittest_require_at_least(skl2onnx, '1.5.9999') | ||
@skipif_circleci("too long") | ||
@ignore_warnings(category=(UserWarning, ConvergenceWarning, RuntimeWarning)) | ||
def test_validate_sklearn_operators_dump_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_dump_all") | ||
self.assertRaise(lambda: list(enumerate_validated_operator_opsets( | ||
verbose, models={"DecisionTreeClassifier"}, | ||
filter_exp=lambda m, p: '64' not in p, | ||
fLOG=fLOG, dump_all=True)), | ||
ValueError) | ||
rows = list(enumerate_validated_operator_opsets( | ||
verbose, models={"DecisionTreeClassifier"}, | ||
filter_exp=lambda m, p: '64' not in p, | ||
fLOG=fLOG, dump_all=True, | ||
dump_folder=temp)) | ||
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) | ||
|
||
stored = os.path.join( | ||
temp, "dump-i-python-DecisionTreeClassifier-default-b-cl-tree._classes.DecisionTreeClassifierzipmapFalse-op11-nf4.pkl") | ||
with open(stored, "rb") as f: | ||
obj = pickle.load(f) | ||
self.assertIn('onnx_bytes', obj) | ||
self.assertIn('skl_model', obj) | ||
self.assertIn('X_test', obj) | ||
self.assertIn('Xort_test', obj) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters