-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
TypeError when fitting GridSearchCV or RandomizedSearchCV with OrdinalEncoder and OneHotEncoder in parameters grid #29157
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
Comments
Could you please provide a minimal reproducer?
|
Thanks for your comment. I modified the issue's description accordingly. |
This seems to be another one related to dtypes of the result in grid search. @lesteve @MarcoGorelli WDYT? |
I can confirm this still happens in This is possible that this is the dtype tweak in grid-search |
thanks for the ping - this seems to be the issue: (Pdb) p param_list
[OneHotEncoder(sparse_output=False), OrdinalEncoder()]
(Pdb) p np.result_type(*param_list)
dtype('float64')
(Pdb) p np.array(param_list).dtype
dtype('O') I find it a bit surprising that |
wait wut
|
Oh dear, |
In a sense, it does make sense that |
I think that creates other issues #28352 (comment) which @thomasjpfan wanted to avoid It might be simplest to just check if any object in Got a call coming up but I can submit a pr later |
Not everything is a We could check if anything is not a scaler of a simple object maybe? Not sure. |
Ah thanks A third-party estimator should still implement fit and predict/transform though? Maybe just check for those attributes? As an aside, I expect that the |
Checking for |
It's good to have a fix in scikit-learn, but I think the numpy behaviour is unexpected so I opened numpy/numpy#26612. |
Describe the bug
Having both
OrdinalEncoder
andOneHotEncoder
inside the parameters grid to be used by theGridSearchCV
orRandomizedSearchCV
results in the following error:TypeError: float() argument must be a string or a real number, not 'OneHotEncoder'
.Steps/Code to Reproduce
Expected Results
I would have expected the pipeline to run without errors, like that:

Actual Results
Versions
The text was updated successfully, but these errors were encountered: