-
Notifications
You must be signed in to change notification settings - Fork 96
/
test_sklearn_svm_converters.py
695 lines (648 loc) · 23.7 KB
/
test_sklearn_svm_converters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
# SPDX-License-Identifier: Apache-2.0
"""
Tests scikit-linear converter.
"""
import unittest
import packaging.version as pv
import numpy
from numpy.testing import assert_almost_equal
from sklearn.datasets import load_iris
from sklearn.svm import SVC, SVR, NuSVC, NuSVR, OneClassSVM, LinearSVC
try:
from skl2onnx.common._apply_operation import apply_less
except ImportError:
# onnxconverter-common is too old
apply_less = None
from skl2onnx import convert_sklearn
from skl2onnx.common.data_types import (
BooleanTensorType,
FloatTensorType,
Int64TensorType,
)
from skl2onnx.operator_converters.ada_boost import _scikit_learn_before_022
from onnxruntime import __version__ as ort_version
from test_utils import (
dump_data_and_model,
fit_regression_model,
TARGET_OPSET,
InferenceSessionEx as InferenceSession,
)
ort_version = ort_version.split("+")[0]
class TestSklearnSVM(unittest.TestCase):
def _fit_binary_classification(self, model):
iris = load_iris()
X = iris.data[:, :3]
y = iris.target
y[y == 2] = 1
model.fit(X, y)
return model, X[:5].astype(numpy.float32)
def _fit_one_class_svm(self, model):
iris = load_iris()
X = iris.data[:, :3]
model.fit(X)
return model, X[10:15].astype(numpy.float32)
def _fit_multi_classification(self, model, nbclass=4):
iris = load_iris()
X = iris.data[:, :3]
y = iris.target
if nbclass == 4:
y[-10:] = 3
model.fit(X, y)
X = numpy.vstack([X[:2], X[-3:]])
return model, X.astype(numpy.float32)
def _fit_multi_regression(self, model):
iris = load_iris()
X = iris.data[:, :3]
y = numpy.vstack([iris.target, iris.target]).T
model.fit(X, y)
return model, X[:5].astype(numpy.float32)
def _check_attributes(self, node, attribute_test):
attributes = node.attribute
attribute_map = {}
for attribute in attributes:
attribute_map[attribute.name] = attribute
for k, v in attribute_test.items():
self.assertTrue(k in attribute_map)
if v is not None:
attrib = attribute_map[k]
if isinstance(v, str):
self.assertEqual(attrib.s, v.encode(encoding="UTF-8"))
elif isinstance(v, int):
self.assertEqual(attrib.i, v)
elif isinstance(v, float):
self.assertEqual(attrib.f, v)
elif isinstance(v, list):
self.assertEqual(attrib.ints, v)
else:
self.fail("Unknown type")
def test_convert_svc_binary_linear_pfalse(self):
model, X = self._fit_binary_classification(
SVC(kernel="linear", probability=False, decision_function_shape="ovo")
)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
svc_node = nodes[0]
self._check_attributes(
svc_node,
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "LINEAR",
"post_transform": None,
"rho": None,
"support_vectors": None,
"vectors_per_class": None,
},
)
dump_data_and_model(
X, model, model_onnx, basename="SklearnBinSVCLinearPF-NoProbOpp"
)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
options={id(model): {"zipmap": False}},
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
dump_data_and_model(
X, model, model_onnx, basename="SklearnBinSVCLinearPF-NoProbOpp"
)
def test_convert_svc_binary_linear_ptrue(self):
model, X = self._fit_binary_classification(
SVC(kernel="linear", probability=True)
)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
svc_node = nodes[0]
self._check_attributes(
svc_node,
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "LINEAR",
"post_transform": None,
"rho": None,
"support_vectors": None,
"vectors_per_class": None,
},
)
dump_data_and_model(X, model, model_onnx, basename="SklearnBinSVCLinearPT")
def test_convert_svc_multi_linear_pfalse(self):
model, X = self._fit_multi_classification(
SVC(kernel="linear", probability=False, decision_function_shape="ovo")
)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
svc_node = nodes[0]
self._check_attributes(
svc_node,
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "LINEAR",
"post_transform": None,
"rho": None,
"support_vectors": None,
"vectors_per_class": None,
},
)
dump_data_and_model(X, model, model_onnx, basename="SklearnMclSVCLinearPF-Dec4")
@unittest.skipIf(apply_less is None, reason="onnxconverter-common old")
def test_convert_svc_multi_linear_pfalse_ovr(self):
model, X = self._fit_multi_classification(
SVC(kernel="linear", probability=False, decision_function_shape="ovr")
)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
dump_data_and_model(X, model, model_onnx, basename="SklearnMclSVCOVR-Dec4")
def test_convert_svc_multi_linear_ptrue(self):
model, X = self._fit_multi_classification(
SVC(kernel="linear", probability=True), nbclass=3
)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
svc_node = nodes[0]
self._check_attributes(
svc_node,
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "LINEAR",
"post_transform": None,
"rho": None,
"support_vectors": None,
"vectors_per_class": None,
},
)
dump_data_and_model(X, model, model_onnx, basename="SklearnMclSVCLinearPT-Dec2")
@unittest.skipIf(
pv.Version(ort_version) <= pv.Version("0.4.0"),
reason="use of recent Cast operator",
)
def test_convert_svr_linear(self):
model, X = self._fit_binary_classification(SVR(kernel="linear"))
model_onnx = convert_sklearn(
model,
"SVR",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
self._check_attributes(
nodes[0],
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "LINEAR",
"post_transform": None,
"rho": None,
"support_vectors": None,
},
)
dump_data_and_model(X, model, model_onnx, basename="SklearnRegSVRLinear-Dec3")
def test_convert_nusvc_binary_pfalse(self):
model, X = self._fit_binary_classification(
NuSVC(probability=False, decision_function_shape="ovo")
)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
svc_node = nodes[0]
self._check_attributes(
svc_node,
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "RBF",
"post_transform": None,
"rho": None,
"support_vectors": None,
"vectors_per_class": None,
},
)
dump_data_and_model(
X, model, model_onnx, basename="SklearnBinNuSVCPF-NoProbOpp"
)
@unittest.skipIf(
pv.Version(ort_version) <= pv.Version("0.4.0"),
reason="use of recent Cast operator",
)
def test_convert_nusvc_binary_ptrue(self):
model, X = self._fit_binary_classification(NuSVC(probability=True))
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
svc_node = nodes[0]
self._check_attributes(
svc_node,
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "RBF",
"post_transform": None,
"rho": None,
"support_vectors": None,
"vectors_per_class": None,
},
)
dump_data_and_model(X, model, model_onnx, basename="SklearnBinNuSVCPT")
def test_convert_nusvc_multi_pfalse(self):
model, X = self._fit_multi_classification(
NuSVC(probability=False, nu=0.1, decision_function_shape="ovo")
)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
svc_node = nodes[0]
self._check_attributes(
svc_node,
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "RBF",
"post_transform": None,
"rho": None,
"support_vectors": None,
"vectors_per_class": None,
},
)
dump_data_and_model(X, model, model_onnx, basename="SklearnMclNuSVCPF-Dec1")
def test_convert_svc_multi_pfalse_4(self):
model, X = self._fit_multi_classification(
SVC(probability=False, decision_function_shape="ovo"), 4
)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
dump_data_and_model(X, model, model_onnx, basename="SklearnMcSVCPF")
@unittest.skipIf(
_scikit_learn_before_022(), reason="break_ties introduced after 0.22"
)
def test_convert_svc_multi_pfalse_4_break_ties(self):
model, X = self._fit_multi_classification(
SVC(probability=True, break_ties=True), 4
)
model_onnx = convert_sklearn(
model,
"unused",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
dump_data_and_model(
X.astype(numpy.float32),
model,
model_onnx,
basename="SklearnMcSVCPFBTF-Dec4",
)
def test_convert_svc_multi_ptrue_4(self):
model, X = self._fit_multi_classification(SVC(probability=True), 4)
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
dump_data_and_model(X, model, model_onnx, basename="SklearnMcSVCPF4-Dec4")
def test_convert_nusvc_multi_ptrue(self):
model, X = self._fit_multi_classification(NuSVC(probability=True, nu=0.1))
model_onnx = convert_sklearn(
model,
"SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
nodes = model_onnx.graph.node
self.assertIsNotNone(nodes)
svc_node = nodes[0]
self._check_attributes(
svc_node,
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "RBF",
"post_transform": None,
"rho": None,
"support_vectors": None,
"vectors_per_class": None,
},
)
dump_data_and_model(X, model, model_onnx, basename="SklearnMclNuSVCPT-Dec3")
@unittest.skipIf(
pv.Version(ort_version) <= pv.Version("0.4.0"),
reason="use of recent Cast operator",
)
def test_convert_nusvr(self):
model, X = self._fit_binary_classification(NuSVR())
model_onnx = convert_sklearn(
model,
"SVR",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
node = model_onnx.graph.node[0]
self.assertIsNotNone(node)
self._check_attributes(
node,
{
"coefficients": None,
"kernel_params": None,
"kernel_type": "RBF",
"post_transform": None,
"rho": None,
"support_vectors": None,
},
)
dump_data_and_model(X, model, model_onnx, basename="SklearnRegNuSVR")
@unittest.skipIf(
pv.Version(ort_version) <= pv.Version("0.4.0"),
reason="use of recent Cast operator",
)
def test_convert_nusvr_default(self):
model, X = self._fit_binary_classification(NuSVR())
model_onnx = convert_sklearn(
model,
"SVR",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
self.assertIsNotNone(model_onnx)
dump_data_and_model(X, model, model_onnx, basename="SklearnRegNuSVR2")
def test_convert_svr_int(self):
model, X = fit_regression_model(SVR(), is_int=True)
model_onnx = convert_sklearn(
model,
"SVR",
[("input", Int64TensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
self.assertIsNotNone(model_onnx)
dump_data_and_model(X, model, model_onnx, basename="SklearnSVRInt-Dec4")
def test_convert_nusvr_int(self):
model, X = fit_regression_model(NuSVR(), is_int=True)
model_onnx = convert_sklearn(
model,
"NuSVR",
[("input", Int64TensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
self.assertIsNotNone(model_onnx)
dump_data_and_model(X, model, model_onnx, basename="SklearnNuSVRInt-Dec4")
def test_convert_svr_bool(self):
model, X = fit_regression_model(SVR(), is_bool=True)
model_onnx = convert_sklearn(
model,
"SVR",
[("input", BooleanTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
self.assertIsNotNone(model_onnx)
dump_data_and_model(X, model, model_onnx, basename="SklearnSVRBool-Dec4")
def test_convert_nusvr_bool(self):
model, X = fit_regression_model(NuSVR(), is_bool=True)
model_onnx = convert_sklearn(
model,
"NuSVR",
[("input", BooleanTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
self.assertIsNotNone(model_onnx)
dump_data_and_model(X, model, model_onnx, basename="SklearnNuSVRBool")
@unittest.skipIf(TARGET_OPSET < 9, reason="operator sign available since opset 9")
def test_convert_oneclasssvm(self):
model, X = self._fit_one_class_svm(OneClassSVM())
model_onnx = convert_sklearn(
model,
"OCSVM",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
dump_data_and_model(X, model, model_onnx, basename="SklearnBinOneClassSVM")
def test_model_linear_svc_binary_class(self):
model, X = self._fit_binary_classification(LinearSVC(max_iter=10000))
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.decision_function(X)
assert_almost_equal(proba, res[1].ravel(), decimal=5)
assert_almost_equal(label, res[0])
def test_model_linear_svc_multi_class(self):
model, X = self._fit_multi_classification(LinearSVC(max_iter=10000))
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.decision_function(X)
assert_almost_equal(proba, res[1], decimal=5)
assert_almost_equal(label, res[0])
def test_model_svc_binary_class_false(self):
model, X = self._fit_binary_classification(SVC(max_iter=10000))
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.decision_function(X)
assert_almost_equal(proba, res[1][:, 0], decimal=5)
assert_almost_equal(label, res[0])
@unittest.skipIf(TARGET_OPSET < 12, reason="operator Less")
def test_model_svc_multi_class_false(self):
model, X = self._fit_multi_classification(SVC(max_iter=10000))
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.decision_function(X)
assert_almost_equal(proba, res[1], decimal=5)
assert_almost_equal(label, res[0])
def test_model_svc_binary_class_true(self):
model, X = self._fit_binary_classification(
SVC(max_iter=10000, probability=True)
)
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
options={"zipmap": False},
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.predict_proba(X)
assert_almost_equal(proba, res[1], decimal=5)
assert_almost_equal(label, res[0])
def test_model_svc_multi_class_true(self):
model, X = self._fit_multi_classification(SVC(max_iter=10000, probability=True))
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
options={"zipmap": False},
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.predict_proba(X)
assert_almost_equal(proba, res[1], decimal=5)
assert_almost_equal(label, res[0])
def test_model_nusvc_binary_class_false(self):
model, X = self._fit_binary_classification(NuSVC(max_iter=10000))
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.decision_function(X)
assert_almost_equal(proba, res[1][:, 0], decimal=5)
assert_almost_equal(label, res[0])
@unittest.skipIf(TARGET_OPSET < 12, reason="operator Less")
def test_model_nusvc_multi_class_false(self):
model, X = self._fit_multi_classification(NuSVC(max_iter=10000, nu=0.1))
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.decision_function(X)
assert_almost_equal(proba, res[1], decimal=4)
assert_almost_equal(label, res[0])
def test_model_nusvc_binary_class_true(self):
model, X = self._fit_binary_classification(
NuSVC(max_iter=10000, probability=True)
)
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
options={"zipmap": False},
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.predict_proba(X)
assert_almost_equal(proba, res[1], decimal=5)
assert_almost_equal(label, res[0])
def test_model_nusvc_multi_class_true(self):
model, X = self._fit_multi_classification(
NuSVC(max_iter=10000, probability=True, nu=0.1)
)
model_onnx = convert_sklearn(
model,
"linear SVC",
[("input", FloatTensorType([None, X.shape[1]]))],
options={"zipmap": False},
target_opset=TARGET_OPSET,
)
sess = InferenceSession(
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
)
res = sess.run(None, {"input": X})
label = model.predict(X)
proba = model.predict_proba(X)
assert_almost_equal(proba, res[1], decimal=3)
assert_almost_equal(label, res[0])
if __name__ == "__main__":
unittest.main(verbosity=2)