Skip to content

Commit 1dad533

Browse files
author
Pierre Bartet
committed
Rely on a public sklearn attribute instead of a private one
Signed-off-by: Pierre Bartet <[email protected]>
1 parent 00e9045 commit 1dad533

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

skl2onnx/shape_calculators/feature_selection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def calculate_sklearn_select(operator):
99
check_input_and_output_numbers(operator, output_count_range=1)
1010
i = operator.inputs[0]
1111
N = i.get_first_dimension()
12-
C = operator.raw_operator._get_support_mask().sum()
12+
C = operator.raw_operator.get_support().sum()
1313
operator.outputs[0].type = i.type.__class__([N, C])
1414

1515

tests/test_sklearn_feature_selection_converters.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ def test_generic_univariate_select_int(self):
5151
X, model, model_onnx, basename="SklearnGenericUnivariateSelect"
5252
)
5353

54+
def test_generic_univariate_select_kbest_int(self):
55+
model = GenericUnivariateSelect(mode="k_best", param=2)
56+
57+
X = np.array(
58+
[[1, 2, 3, 1], [0, 3, 1, 4], [3, 5, 6, 1], [1, 2, 1, 5]], dtype=np.int64
59+
)
60+
y = np.array([0, 1, 0, 1])
61+
model.fit(X, y)
62+
63+
model_onnx = convert_sklearn(
64+
model,
65+
"generic univariate select",
66+
[("input", Int64TensorType([None, X.shape[1]]))],
67+
target_opset=TARGET_OPSET,
68+
)
69+
self.assertTrue(model_onnx is not None)
70+
dump_data_and_model(
71+
X, model, model_onnx, basename="SklearnGenericUnivariateSelect"
72+
)
73+
5474
def test_rfe_int(self):
5575
model = RFE(estimator=SVR(kernel="linear"))
5676
X = np.array(

0 commit comments

Comments
 (0)