Skip to content
Advertisement

__init__() got an unexpected keyword argument ‘handle_unknown’

I’m trying to Ordinal Encode my categorical features using sklearn, but I get the error __init__() got an unexpected keyword argument 'handle_unknown' when I compile the below code:

JavaScript

A sample data to reproduce the error:

JavaScript

Could someone please tell me what’s wrong in my code?

Advertisement

Answer

You are most likely not using an appropriate version of scikit-learn.

handle_unknown and unknown_value were added to OrdinalEncoder with the release of version 0.24.0 (see release history).

Check your version of scikit-learn and upgrade if necessary.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement