hypopt icon indicating copy to clipboard operation
hypopt copied to clipboard

module 'sklearn.metrics' has no attribute 'scorer' with sklearn 0.23.0

Open fcoppey opened this issue 4 years ago • 5 comments

I just updated sklearn to 0.23.0 and now hypopt .fit() function raises this error where using scoring='accuracy' with sklearn LocalOutlierFactor(): /usr/local/lib/python3.7/site-packages/hypopt/model_selection.py:174: UserWarning: ERROR in thread<NoDaemonProcess(NoDaemonPoolWorker-2, started)>with exception: module 'sklearn.metrics' has no attribute 'scorer'. Any compatibility issues with latest sklearn?

fcoppey avatar May 19 '20 11:05 fcoppey

scorer becomes a private API in newer version of sklearn. One fix to this is to change those metrics.scorer to metrics._scorer in the model_selection.py.

YUHENGLEEEEE avatar May 21 '20 13:05 YUHENGLEEEEE

@YUHENGLEEEEE thanks Steve, please submit a pull request?

cgnorthcutt avatar May 21 '20 14:05 cgnorthcutt

are you going to update the package?

fcoppey avatar Jun 12 '20 08:06 fcoppey

Hi all, I see that there is an issue with latest versions of sklearn (>=0.22.X) and that scorer has become a private API starting from version 0.22. Anyway, since here the problem was raised with parameter scoring='accuracy' I can't see how this is related to the solution which was specified above.

Can anyone help? Thank you :)

AlessandroMiola avatar Dec 06 '20 16:12 AlessandroMiola

Hi all, I have eventually figured the issue out. The solution specified above is indeed the correct one.

My feeling was that, with non-custom scoring parameters, the fact that sklearn.metrics.scorer is no more existent (as replaced by sklearn.metrics._scorer) could have been circumvented. I was wrong as an exception is thrown before the else-clause responsible for the computation of scores with non-custom scoring parameters can be even reached.

AlessandroMiola avatar Dec 14 '20 20:12 AlessandroMiola