Coverage for mlprodict/asv_benchmark/template/skl_model_outlier.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

12 statements  

1""" 

2A template to benchmark a model 

3with :epkg:`asv`. The benchmark can be run through 

4file :epkg:`run_asv.sh` on Linux or :epkg:`run_asv.bat` 

5on Windows. 

6 

7.. warning:: 

8 On Windows, you should avoid cloning the repository 

9 on a folder with a long full name. Visual Studio tends to 

10 abide by the rule of the maximum path length even though 

11 the system is told otherwise. 

12""" 

13import numpy # pylint: disable=W0611 

14from mlprodict import __max_supported_opset__ 

15# Import specific to this model. 

16from sklearn.svm import OneClassSVM # pylint: disable=C0411 

17 

18from mlprodict.asv_benchmark import _CommonAsvSklBenchmarkOutlier # pylint: disable=C0412 

19from mlprodict.onnx_conv import to_onnx # pylint: disable=W0611, C0412 

20from mlprodict.onnxrt import OnnxInference # pylint: disable=W0611, C0412 

21 

22 

23class TemplateBenchmarkOutlier(_CommonAsvSklBenchmarkOutlier): 

24 """ 

25 :epkg:`asv` example for an outlier detector, 

26 Full template can be found in 

27 `common_asv_skl.py <https://github.com/sdpython/mlprodict/blob/ 

28 master/mlprodict/asv_benchmark/common_asv_skl.py>`_. 

29 """ 

30 params = [ 

31 ['skl', 'pyrtc', 'ort'], # values for runtime 

32 [1, 10, 100, 1000, 10000], # values for N 

33 [4, 20], # values for nf 

34 [__max_supported_opset__], # values for opset 

35 ['float', 'double'], # values for dtype 

36 [None], # values for optim 

37 ] 

38 

39 # additional parameters 

40 

41 def setup_cache(self): # pylint: disable=W0235 

42 super().setup_cache() 

43 

44 def _create_model(self): 

45 return OneClassSVM()