From 79542dd37729cd8a95f86922acc0271e00b6dd76 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 26 Jan 2023 15:29:00 -0800 Subject: [PATCH] [Automated]: Update Python API docs (#14427) Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action Co-authored-by: fs-eire --- .../python/auto_examples/plot_backend.html | 2 +- .../plot_convert_pipeline_vectorizer.html | 6 +- .../auto_examples/plot_load_and_predict.html | 26 ++--- .../python/auto_examples/plot_pipeline.html | 4 +- .../python/auto_examples/plot_profiling.html | 16 +-- .../plot_train_convert_predict.html | 98 +++++++++-------- .../auto_examples/sg_execution_times.html | 20 ++-- .../auto_examples_python.zip | Bin 23566 -> 23566 bytes .../auto_examples_jupyter.zip | Bin 40962 -> 40962 bytes ...phx_glr_plot_train_convert_predict_001.png | Bin 30065 -> 30134 bytes ...x_glr_plot_train_convert_predict_thumb.png | Bin 23243 -> 23260 bytes docs/api/python/searchindex.js | 2 +- .../auto_examples/plot_backend.rst.txt | 2 +- .../plot_convert_pipeline_vectorizer.rst.txt | 6 +- .../plot_load_and_predict.rst.txt | 26 ++--- .../auto_examples/plot_pipeline.rst.txt | 4 +- .../auto_examples/plot_profiling.rst.txt | 16 +-- .../plot_train_convert_predict.rst.txt | 101 ++++++++++-------- .../auto_examples/sg_execution_times.rst.txt | 14 +-- docs/api/python/tutorial.html | 18 +--- 20 files changed, 188 insertions(+), 173 deletions(-) diff --git a/docs/api/python/auto_examples/plot_backend.html b/docs/api/python/auto_examples/plot_backend.html index b2318a5937..7ef17f6000 100644 --- a/docs/api/python/auto_examples/plot_backend.html +++ b/docs/api/python/auto_examples/plot_backend.html @@ -112,7 +112,7 @@ without using onnx.

The backend API is implemented by other frameworks and makes it easier to switch between multiple runtimes with the same API.

-

Total running time of the script: ( 0 minutes 0.016 seconds)

+

Total running time of the script: ( 0 minutes 0.014 seconds)

-
0.9358557991605122
+
0.8778842817557302
 
@@ -200,12 +200,12 @@ ONNX Runtime expects one observation at a time.

print(r2_score(pred, pred_onx))
 
-
0.9999999999999337
+
0.999999999999964
 

Very similar. ONNX Runtime uses floats instead of doubles, that explains the small discrepencies.

-

Total running time of the script: ( 0 minutes 1.066 seconds)

+

Total running time of the script: ( 0 minutes 1.044 seconds)

-
[array([[[0.5179582 , 0.61270964, 0.61406195, 0.5725736 , 0.51330644],
-        [0.69485235, 0.5532911 , 0.52013624, 0.636309  , 0.70414793],
-        [0.6428818 , 0.63155353, 0.6381408 , 0.5325222 , 0.63684714],
-        [0.71618   , 0.54053146, 0.7182288 , 0.54457587, 0.67911494]],
+
[array([[[0.7074605 , 0.66807246, 0.5468252 , 0.6794102 , 0.72581375],
+        [0.7061233 , 0.7108102 , 0.7131539 , 0.5087233 , 0.7157812 ],
+        [0.5101798 , 0.6822957 , 0.71132684, 0.63517916, 0.5935693 ],
+        [0.6674769 , 0.71915364, 0.6055379 , 0.6265797 , 0.6334329 ]],
 
-       [[0.54977566, 0.69168943, 0.56264675, 0.7119333 , 0.6331944 ],
-        [0.6970906 , 0.6601206 , 0.6880265 , 0.50476724, 0.71472955],
-        [0.72150964, 0.7020236 , 0.65242076, 0.58242726, 0.5292552 ],
-        [0.5488381 , 0.5718334 , 0.5828182 , 0.68686056, 0.7161767 ]],
+       [[0.7060813 , 0.65122193, 0.5852989 , 0.7020965 , 0.5418902 ],
+        [0.70865536, 0.7239054 , 0.53950447, 0.6397851 , 0.61991036],
+        [0.5108298 , 0.70998025, 0.5768114 , 0.70231366, 0.7083629 ],
+        [0.5532729 , 0.6634668 , 0.68702626, 0.53754365, 0.63848865]],
 
-       [[0.6186368 , 0.5709658 , 0.59708256, 0.627766  , 0.64522445],
-        [0.6574453 , 0.63655937, 0.6999107 , 0.70128393, 0.65033275],
-        [0.5789951 , 0.61559284, 0.66066134, 0.6682638 , 0.69809294],
-        [0.697786  , 0.6425333 , 0.6025326 , 0.6508598 , 0.62747025]]],
+       [[0.5546355 , 0.5326628 , 0.6045945 , 0.72216797, 0.5367474 ],
+        [0.54598904, 0.683926  , 0.7086522 , 0.5805207 , 0.6906233 ],
+        [0.71620524, 0.6052958 , 0.7310034 , 0.6245417 , 0.6648243 ],
+        [0.6229709 , 0.5226055 , 0.67183244, 0.6684347 , 0.57293963]]],
       dtype=float32)]
 
-

Total running time of the script: ( 0 minutes 0.009 seconds)

+

Total running time of the script: ( 0 minutes 0.007 seconds)

-plot pipeline
<matplotlib.image.AxesImage object at 0x7effb65e3d90>
+plot pipeline
<matplotlib.image.AxesImage object at 0x7f0fecf2bd90>
 
-

Total running time of the script: ( 0 minutes 0.221 seconds)

+

Total running time of the script: ( 0 minutes 0.136 seconds)

-
onnxruntime_profile__2023-01-25_17-47-38.json
+
onnxruntime_profile__2023-01-26_22-44-30.json
 

The results are stored un a file in JSON format. @@ -122,20 +122,20 @@ Let’s see what it contains.

[{'args': {},
   'cat': 'Session',
-  'dur': 62,
+  'dur': 59,
   'name': 'model_loading_array',
   'ph': 'X',
-  'pid': 2783,
-  'tid': 2783,
+  'pid': 2745,
+  'tid': 2745,
   'ts': 1},
  {'args': {},
   'cat': 'Session',
-  'dur': 283,
+  'dur': 308,
   'name': 'session_initialization',
   'ph': 'X',
-  'pid': 2783,
-  'tid': 2783,
-  'ts': 76}]
+  'pid': 2745,
+  'tid': 2745,
+  'ts': 73}]
 

Total running time of the script: ( 0 minutes 0.005 seconds)

diff --git a/docs/api/python/auto_examples/plot_train_convert_predict.html b/docs/api/python/auto_examples/plot_train_convert_predict.html index ea36661e60..a570aa8aab 100644 --- a/docs/api/python/auto_examples/plot_train_convert_predict.html +++ b/docs/api/python/auto_examples/plot_train_convert_predict.html @@ -86,6 +86,16 @@ to its use in its converted from.

clr.fit(X_train, y_train)
+
/home/runner/.local/lib/python3.10/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
+STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.
+
+Increase the number of iterations (max_iter) or scale the data as shown in:
+    https://scikit-learn.org/stable/modules/preprocessing.html
+Please also refer to the documentation for alternative solver options:
+    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
+  n_iter_i = _check_optimize_result(
+
+
LogisticRegression()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
@@ -98,9 +108,9 @@ and we show the confusion matrix.

print(confusion_matrix(y_test, pred)) -
[[12  0  0]
- [ 0 12  1]
- [ 0  0 13]]
+
[[14  0  0]
+ [ 0 11  0]
+ [ 0  1 12]]
 
@@ -142,9 +152,9 @@ output name='output_label' and shape=[None] print(confusion_matrix(pred, pred_onx))
-
[[12  0  0]
+
[[14  0  0]
  [ 0 12  0]
- [ 0  0 14]]
+ [ 0  0 12]]
 

The prediction are perfectly identical.

@@ -159,9 +169,9 @@ scikit-learn.

print(prob_sklearn[:3])
-
[[9.64397638e-01 3.56022281e-02 1.33661432e-07]
- [1.12861883e-02 7.36931324e-01 2.51782488e-01]
- [9.71882114e-01 2.81177168e-02 1.68768358e-07]]
+
[[1.90908960e-01 8.02874408e-01 6.21663156e-03]
+ [2.81698299e-02 9.12759445e-01 5.90707247e-02]
+ [9.67801591e-01 3.21983324e-02 7.64754321e-08]]
 

And then with ONNX Runtime. @@ -174,9 +184,9 @@ The probabilies appear to be

pprint.pprint(prob_rt[0:3])
-
[{0: 0.964397668838501, 1: 0.03560224175453186, 2: 1.3366144457904738e-07},
- {0: 0.01128618698567152, 1: 0.7369312644004822, 2: 0.25178253650665283},
- {0: 0.9718821048736572, 1: 0.028117714449763298, 2: 1.6876846586910688e-07}]
+
[{0: 0.19090914726257324, 1: 0.8028742074966431, 2: 0.0062166303396224976},
+ {0: 0.02816985361278057, 1: 0.9127594232559204, 2: 0.059070732444524765},
+ {0: 0.9678016304969788, 1: 0.03219832107424736, 2: 7.647536648391906e-08}]
 

Let’s benchmark.

@@ -200,11 +210,11 @@ The probabilies appear to be

Execution time for clr.predict
-Average 4.45e-05 min=4.23e-05 max=5.86e-05
+Average 4.44e-05 min=4.24e-05 max=5.4e-05
 Execution time for ONNX Runtime
-Average 2.2e-05 min=2.14e-05 max=2.68e-05
+Average 2.21e-05 min=2.16e-05 max=2.71e-05
 
-2.1959864999132605e-05
+2.2087500000509407e-05
 

Let’s benchmark a scenario similar to what a webservice @@ -232,11 +242,11 @@ as opposed to a batch of prediction.

Execution time for clr.predict
-Average 0.00412 min=0.00409 max=0.00419
+Average 0.00406 min=0.00404 max=0.00414
 Execution time for sess_predict
-Average 0.00102 min=0.00101 max=0.00105
+Average 0.00104 min=0.00102 max=0.00107
 
-0.0010201415149995795
+0.00103513229499967
 

Let’s do the same for the probabilities.

@@ -253,11 +263,11 @@ Average 0.00102 min=0.00101 max=0.00105
Execution time for predict_proba
-Average 0.0062 min=0.00618 max=0.00622
+Average 0.0061 min=0.00608 max=0.00626
 Execution time for sess_predict_proba
 Average 0.00108 min=0.00107 max=0.0011
 
-0.0010763829249992797
+0.001081757285000009
 

This second comparison is better as @@ -295,11 +305,11 @@ in every case.

Execution time for predict_proba
-Average 0.676 min=0.675 max=0.678
+Average 0.674 min=0.672 max=0.678
 Execution time for sess_predict_proba
-Average 0.00136 min=0.00132 max=0.00164
+Average 0.0013 min=0.00129 max=0.00133
 
-0.0013557706149995852
+0.001301839815000676
 

Let’s see with different number of trees.

@@ -334,40 +344,40 @@ Average 0.00136 min=0.00132 max=0.00164 Speed comparison between scikit-learn and ONNX Runtime For a random forest on Iris dataset
5
-Average 0.0492 min=0.0491 max=0.0493
-Average 0.00102 min=0.00101 max=0.00104
+Average 0.0491 min=0.049 max=0.0491
+Average 0.00103 min=0.00102 max=0.00105
 10
-Average 0.0825 min=0.0824 max=0.0827
-Average 0.00105 min=0.00104 max=0.00107
+Average 0.0823 min=0.0822 max=0.0824
+Average 0.00104 min=0.00102 max=0.00106
 15
-Average 0.116 min=0.116 max=0.116
-Average 0.00104 min=0.00103 max=0.00107
+Average 0.115 min=0.115 max=0.115
+Average 0.00103 min=0.00102 max=0.00106
 20
-Average 0.149 min=0.149 max=0.149
-Average 0.00106 min=0.00105 max=0.00108
+Average 0.148 min=0.148 max=0.148
+Average 0.00105 min=0.00104 max=0.00108
 25
-Average 0.182 min=0.182 max=0.184
-Average 0.00108 min=0.00107 max=0.0011
+Average 0.181 min=0.181 max=0.182
+Average 0.00107 min=0.00106 max=0.00109
 30
-Average 0.215 min=0.214 max=0.215
-Average 0.00108 min=0.00108 max=0.0011
+Average 0.214 min=0.214 max=0.214
+Average 0.00107 min=0.00106 max=0.00109
 35
-Average 0.248 min=0.247 max=0.248
-Average 0.0011 min=0.00108 max=0.00113
+Average 0.247 min=0.247 max=0.248
+Average 0.00109 min=0.00108 max=0.00111
 40
-Average 0.281 min=0.281 max=0.281
-Average 0.0011 min=0.00109 max=0.00113
+Average 0.28 min=0.279 max=0.28
+Average 0.00109 min=0.00108 max=0.00112
 45
-Average 0.314 min=0.314 max=0.314
-Average 0.0011 min=0.00109 max=0.00113
+Average 0.312 min=0.311 max=0.312
+Average 0.00112 min=0.00111 max=0.00115
 50
-Average 0.347 min=0.347 max=0.348
-Average 0.00113 min=0.00112 max=0.00116
+Average 0.345 min=0.344 max=0.345
+Average 0.00112 min=0.00111 max=0.00114
 
-<matplotlib.legend.Legend object at 0x7eff9f4d4400>
+<matplotlib.legend.Legend object at 0x7f0fd5bd2a40>
 
-

Total running time of the script: ( 3 minutes 8.827 seconds)

+

Total running time of the script: ( 3 minutes 8.150 seconds)