Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrdinalEncoder handle encoded_missing_value and unknown_value #1132

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LLukas22
Copy link

In the current version of sklearn-onnx, the encoded_missing_value and unknown_value parameters of the OrdinalEncoder in scikit-learn are not properly handled. Specifically, these parameters are ignored during the ONNX model conversion.

For example, if we create an OrdinalEncoder with encoded_missing_value set to 42 and fit it on the following data: np.array([["a"], ["b"], ["c"], ["d"], [np.nan]], dtype=np.object_), scikit-learn produces the expected output: [0, 1, 2, 3, 42]. However, the converted ONNX model does not respect the encoded_missing_value parameter, leading to an unexpected result: [0, 1, 2, 3, 4].

Similarly, the unknown_value parameter is also ignored during conversion, which affects the expected output. To address this issue, the default_int64 parameter of the ONNX LabelEncoder needs to be set when an unknown_value is specified.

I have included some tests to demonstrate this behavior and implemented a simple fix to resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant