Skip to content

Commit d97fba7

Browse files
committed
fix
Signed-off-by: Xavier Dupré <[email protected]>
1 parent c551cc9 commit d97fba7

File tree

2 files changed

+7
-54
lines changed

2 files changed

+7
-54
lines changed

skl2onnx/operator_converters/ordinal_encoder.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ def convert_sklearn_ordinal_encoder(
4343
)
4444

4545
ordinal_categories = ordinal_op.categories_
46-
if (
47-
hasattr(ordinal_op, "infrequent_categories_")
48-
and ordinal_op.infrequent_categories_
49-
):
50-
# exclude infrequent categories if present
51-
ordinal_categories = [
52-
categories
53-
for categories in ordinal_categories
54-
if categories not in ordinal_op.infrequent_categories_
55-
]
5646

5747
for categories in ordinal_categories:
5848
if len(categories) == 0:

tests/test_sklearn_ordinal_encoder.py

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,7 @@ def test_model_ordinal_encoder_encoded_missing_value(self):
254254
sess = InferenceSession(
255255
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
256256
)
257-
got = sess.run(
258-
None,
259-
{
260-
"input": data,
261-
},
262-
)
257+
got = sess.run(None, {"input": data})
263258

264259
assert_almost_equal(expected.reshape(-1), got[0].reshape(-1))
265260

@@ -292,12 +287,7 @@ def test_model_ordinal_encoder_encoded_missing_value_no_nan(self):
292287
sess = InferenceSession(
293288
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
294289
)
295-
got = sess.run(
296-
None,
297-
{
298-
"input": data,
299-
},
300-
)
290+
got = sess.run(None, {"input": data})
301291

302292
assert_almost_equal(expected.reshape(-1), got[0].reshape(-1))
303293

@@ -395,9 +385,7 @@ def test_model_ordinal_encoder_max_categories(self):
395385
data = np.array(
396386
[["a"], ["b"], ["c"], ["d"], ["a"], ["b"], ["c"], ["e"]], dtype=np.object_
397387
)
398-
399388
expected = model.fit_transform(data)
400-
401389
model_onnx = convert_sklearn(
402390
model,
403391
"scikit-learn ordinal encoder",
@@ -415,12 +403,7 @@ def test_model_ordinal_encoder_max_categories(self):
415403
sess = InferenceSession(
416404
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
417405
)
418-
got = sess.run(
419-
None,
420-
{
421-
"input": data,
422-
},
423-
)
406+
got = sess.run(None, {"input": data})
424407

425408
assert_almost_equal(expected.reshape(-1), got[0].reshape(-1))
426409

@@ -455,12 +438,7 @@ def test_model_ordinal_encoder_min_frequency(self):
455438
sess = InferenceSession(
456439
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
457440
)
458-
got = sess.run(
459-
None,
460-
{
461-
"input": data,
462-
},
463-
)
441+
got = sess.run(None, {"input": data})
464442

465443
assert_almost_equal(expected.reshape(-1), got[0].reshape(-1))
466444

@@ -495,12 +473,7 @@ def test_model_ordinal_encoder_unknown_value_nan(self):
495473
sess = InferenceSession(
496474
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
497475
)
498-
got = sess.run(
499-
None,
500-
{
501-
"input": data_with_missing_value,
502-
},
503-
)
476+
got = sess.run(None, {"input": data_with_missing_value})
504477

505478
assert_almost_equal(expected.reshape(-1), got[0].reshape(-1))
506479

@@ -559,21 +532,11 @@ def test_model_ordinal_encoder_min_frequency_multi_column(self):
559532
sess = InferenceSession(
560533
model_onnx.SerializeToString(), providers=["CPUExecutionProvider"]
561534
)
562-
got = sess.run(
563-
None,
564-
{
565-
"input": data,
566-
},
567-
)
535+
got = sess.run(None, {"input": data})
568536
assert_almost_equal(expected.reshape(-1), got[0].reshape(-1))
569537

570538
# Test with test data
571-
got_test = sess.run(
572-
None,
573-
{
574-
"input": test_data,
575-
},
576-
)
539+
got_test = sess.run(None, {"input": test_data})
577540
assert_almost_equal(expected_test.reshape(-1), got_test[0].reshape(-1))
578541

579542

0 commit comments

Comments
 (0)