From 6d60de01f62f4fc07e17de3d73c8d85de62a1ead Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Mon, 15 May 2023 04:25:42 +0000 Subject: automatic import of python-mlprodict --- python-mlprodict.spec | 271 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 python-mlprodict.spec (limited to 'python-mlprodict.spec') diff --git a/python-mlprodict.spec b/python-mlprodict.spec new file mode 100644 index 0000000..ba9e88f --- /dev/null +++ b/python-mlprodict.spec @@ -0,0 +1,271 @@ +%global _empty_manifest_terminate_build 0 +Name: python-mlprodict +Version: 0.9.1883 +Release: 1 +Summary: Python Runtime for ONNX models, other helpers to convert machine learned models in C++. +License: MIT +URL: http://www.xavierdupre.fr/app/mlprodict/helpsphinx/index.html +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/5b/d2/7f643bb8432e9c7961becb4f44e0e0f8455dffa92344c6e4ca7b4d18d232/mlprodict-0.9.1883.tar.gz + +Requires: python3-pybind11 +Requires: python3-numpy +Requires: python3-onnx +Requires: python3-scipy +Requires: python3-cython +Requires: python3-jinja2 +Requires: python3-scikit-learn +Requires: python3-skl2onnx +Requires: python3-onnxruntime +Requires: python3-scipy +Requires: python3-pandas +Requires: python3-mlinsights +Requires: python3-lightgbm +Requires: python3-xgboost +Requires: python3-mlstatpy +Requires: python3-onnxruntime-extensions +Requires: python3-scikit-learn +Requires: python3-skl2onnx +Requires: python3-scikit-learn +Requires: python3-skl2onnx +Requires: python3-lightgbm +Requires: python3-mlinsights +Requires: python3-xgboost +Requires: python3-scikit-learn +Requires: python3-skl2onnx +Requires: python3-onnxruntime +Requires: python3-scikit-learn +Requires: python3-onnxruntime +Requires: python3-onnxruntime-extensions + +%description +*mlprodict* was initially started to help implementing converters +to *ONNX*. The main features is a python runtime for +*ONNX* (class `OnnxInference +`_), +visualization tools +(see `Visualization +`_), +and a `numpy API for ONNX +`_). +The package also provides tools to compare +predictions, to benchmark models converted with +`sklearn-onnx `_. + import numpy + from sklearn.linear_model import LinearRegression + from sklearn.datasets import load_iris + from mlprodict.onnxrt import OnnxInference + from mlprodict.onnxrt.validate.validate_difference import measure_relative_difference + from mlprodict import __max_supported_opset__, get_ir_version + iris = load_iris() + X = iris.data[:, :2] + y = iris.target + lr = LinearRegression() + lr.fit(X, y) + # Predictions with scikit-learn. + expected = lr.predict(X[:5]) + print(expected) + # Conversion into ONNX. + from mlprodict.onnx_conv import to_onnx + model_onnx = to_onnx(lr, X.astype(numpy.float32), + black_op={'LinearRegressor'}, + target_opset=__max_supported_opset__) + print("ONNX:", str(model_onnx)[:200] + "\n...") + # Predictions with onnxruntime + model_onnx.ir_version = get_ir_version(__max_supported_opset__) + oinf = OnnxInference(model_onnx, runtime='onnxruntime1') + ypred = oinf.run({'X': X[:5].astype(numpy.float32)}) + print("ONNX output:", ypred) + # Measuring the maximum difference. + print("max abs diff:", measure_relative_difference(expected, ypred['variable'])) + # And the python runtime + oinf = OnnxInference(model_onnx, runtime='python') + ypred = oinf.run({'X': X[:5].astype(numpy.float32)}, + verbose=1, fLOG=print) + print("ONNX output:", ypred) +**Installation** +Installation from *pip* should work unless you need the latest +development features. + pip install mlprodict +The package includes a runtime for *ONNX*. That's why there +is a limited number of dependencies. However, some features +relies on *sklearn-onnx*, *onnxruntime*, *scikit-learn*. +They can be installed with the following instructions: + pip install mlprodict[all] +The code is available at +`GitHub/mlprodict `_ +and has `online documentation `_. + +%package -n python3-mlprodict +Summary: Python Runtime for ONNX models, other helpers to convert machine learned models in C++. +Provides: python-mlprodict +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +BuildRequires: python3-cffi +BuildRequires: gcc +BuildRequires: gdb +%description -n python3-mlprodict +*mlprodict* was initially started to help implementing converters +to *ONNX*. The main features is a python runtime for +*ONNX* (class `OnnxInference +`_), +visualization tools +(see `Visualization +`_), +and a `numpy API for ONNX +`_). +The package also provides tools to compare +predictions, to benchmark models converted with +`sklearn-onnx `_. + import numpy + from sklearn.linear_model import LinearRegression + from sklearn.datasets import load_iris + from mlprodict.onnxrt import OnnxInference + from mlprodict.onnxrt.validate.validate_difference import measure_relative_difference + from mlprodict import __max_supported_opset__, get_ir_version + iris = load_iris() + X = iris.data[:, :2] + y = iris.target + lr = LinearRegression() + lr.fit(X, y) + # Predictions with scikit-learn. + expected = lr.predict(X[:5]) + print(expected) + # Conversion into ONNX. + from mlprodict.onnx_conv import to_onnx + model_onnx = to_onnx(lr, X.astype(numpy.float32), + black_op={'LinearRegressor'}, + target_opset=__max_supported_opset__) + print("ONNX:", str(model_onnx)[:200] + "\n...") + # Predictions with onnxruntime + model_onnx.ir_version = get_ir_version(__max_supported_opset__) + oinf = OnnxInference(model_onnx, runtime='onnxruntime1') + ypred = oinf.run({'X': X[:5].astype(numpy.float32)}) + print("ONNX output:", ypred) + # Measuring the maximum difference. + print("max abs diff:", measure_relative_difference(expected, ypred['variable'])) + # And the python runtime + oinf = OnnxInference(model_onnx, runtime='python') + ypred = oinf.run({'X': X[:5].astype(numpy.float32)}, + verbose=1, fLOG=print) + print("ONNX output:", ypred) +**Installation** +Installation from *pip* should work unless you need the latest +development features. + pip install mlprodict +The package includes a runtime for *ONNX*. That's why there +is a limited number of dependencies. However, some features +relies on *sklearn-onnx*, *onnxruntime*, *scikit-learn*. +They can be installed with the following instructions: + pip install mlprodict[all] +The code is available at +`GitHub/mlprodict `_ +and has `online documentation `_. + +%package help +Summary: Development documents and examples for mlprodict +Provides: python3-mlprodict-doc +%description help +*mlprodict* was initially started to help implementing converters +to *ONNX*. The main features is a python runtime for +*ONNX* (class `OnnxInference +`_), +visualization tools +(see `Visualization +`_), +and a `numpy API for ONNX +`_). +The package also provides tools to compare +predictions, to benchmark models converted with +`sklearn-onnx `_. + import numpy + from sklearn.linear_model import LinearRegression + from sklearn.datasets import load_iris + from mlprodict.onnxrt import OnnxInference + from mlprodict.onnxrt.validate.validate_difference import measure_relative_difference + from mlprodict import __max_supported_opset__, get_ir_version + iris = load_iris() + X = iris.data[:, :2] + y = iris.target + lr = LinearRegression() + lr.fit(X, y) + # Predictions with scikit-learn. + expected = lr.predict(X[:5]) + print(expected) + # Conversion into ONNX. + from mlprodict.onnx_conv import to_onnx + model_onnx = to_onnx(lr, X.astype(numpy.float32), + black_op={'LinearRegressor'}, + target_opset=__max_supported_opset__) + print("ONNX:", str(model_onnx)[:200] + "\n...") + # Predictions with onnxruntime + model_onnx.ir_version = get_ir_version(__max_supported_opset__) + oinf = OnnxInference(model_onnx, runtime='onnxruntime1') + ypred = oinf.run({'X': X[:5].astype(numpy.float32)}) + print("ONNX output:", ypred) + # Measuring the maximum difference. + print("max abs diff:", measure_relative_difference(expected, ypred['variable'])) + # And the python runtime + oinf = OnnxInference(model_onnx, runtime='python') + ypred = oinf.run({'X': X[:5].astype(numpy.float32)}, + verbose=1, fLOG=print) + print("ONNX output:", ypred) +**Installation** +Installation from *pip* should work unless you need the latest +development features. + pip install mlprodict +The package includes a runtime for *ONNX*. That's why there +is a limited number of dependencies. However, some features +relies on *sklearn-onnx*, *onnxruntime*, *scikit-learn*. +They can be installed with the following instructions: + pip install mlprodict[all] +The code is available at +`GitHub/mlprodict `_ +and has `online documentation `_. + +%prep +%autosetup -n mlprodict-0.9.1883 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-mlprodict -f filelist.lst +%dir %{python3_sitearch}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 15 2023 Python_Bot - 0.9.1883-1 +- Package Spec generated -- cgit v1.2.3