Useful functions¶
Links: notebook
, html, PDF
, python
, slides, GitHub
Benchmarks measures performances. It can be useful to know in which context. These are some functions to know better about it.
from jyquickhelper import add_notebook_menu
add_notebook_menu()
%matplotlib inline
Machine¶
from pymlbenchmark.context import machine_information
import numpy
machine_information(['numpy', 'pandas', 'onnx'])
[{'name': 'date', 'version': '2019-03-07'},
{'name': 'python',
'value': '3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)]'},
{'name': 'platform', 'value': 'win32'},
{'name': 'OS', 'value': 'Windows-10-10.0.17134-SP0'},
{'name': 'machine', 'value': 'AMD64'},
{'name': 'processor',
'value': 'Intel64 Family 6 Model 78 Stepping 3, GenuineIntel'},
{'name': 'release', 'value': '10'},
{'name': 'architecture', 'value': ('64bit', 'WindowsPE')},
{'name': 'numpy', 'version': '1.16.2'},
{'name': 'onnx', 'version': 'not-imported'},
{'name': 'pandas', 'version': '0.24.1'}]
import pandas
pandas.DataFrame(machine_information(['numpy', 'pandas', 'onnx']))
name | value | version | |
---|---|---|---|
0 | date | NaN | 2019-03-07 |
1 | python | 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23... | NaN |
2 | platform | win32 | NaN |
3 | OS | Windows-10-10.0.17134-SP0 | NaN |
4 | machine | AMD64 | NaN |
5 | processor | Intel64 Family 6 Model 78 Stepping 3, GenuineI... | NaN |
6 | release | 10 | NaN |
7 | architecture | (64bit, WindowsPE) | NaN |
8 | numpy | NaN | 1.16.2 |
9 | onnx | NaN | not-imported |
10 | pandas | NaN | 0.24.1 |
One benchmark¶
from pymlbenchmark.datasets import experiment_results
df = experiment_results('onnxruntime_LogisticRegression')
df.head()
N | count | dim | fit_intercept | lib | lower | max | max3 | mean | median | method | min | min3 | repeat | upper | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 100 | 1 | True | skl | -0.000014 | 0.000392 | 0.000128 | 0.000071 | 0.000052 | predict | 0.000038 | 0.000039 | 100 | 0.000155 |
1 | 1 | 100 | 1 | True | ort | -0.000008 | 0.000185 | 0.000042 | 0.000025 | 0.000023 | predict | 0.000022 | 0.000022 | 100 | 0.000058 |
2 | 1 | 100 | 1 | True | skl | 0.000028 | 0.000121 | 0.000083 | 0.000051 | 0.000047 | predict_proba | 0.000046 | 0.000046 | 100 | 0.000074 |
3 | 1 | 100 | 1 | True | ort | 0.000014 | 0.000062 | 0.000045 | 0.000026 | 0.000024 | predict_proba | 0.000023 | 0.000024 | 100 | 0.000037 |
4 | 10 | 100 | 1 | True | skl | 0.000020 | 0.000111 | 0.000077 | 0.000043 | 0.000039 | predict | 0.000038 | 0.000039 | 100 | 0.000066 |
from pymlbenchmark.plotting import plot_bench_results
plot_bench_results(df, row_cols='N', col_cols='method',
x_value='dim', hue_cols='fit_intercept',
title="LogisticRegression\nBenchmark scikit-learn / onnxruntime");
