scikit-learn-contrib / metric-learn

Metric learning algorithms in Python
http://contrib.scikit-learn.org/metric-learn/
MIT License
1.4k stars 234 forks source link

Update metric-learn to work with the most recent scikit-learn when doing pytest #311

Closed wdevazelhes closed 3 years ago

wdevazelhes commented 3 years ago

There seems to have been some changes in scikit-learn's new version (0.24): I have the following errors ModuleNotFoundError: No module named 'sklearn.utils.testing' when calling pytest on metric-learn (after a fresh clone of master on a conda env with scikit-learn 0.24). The reason is the one from this comment https://github.com/uber/causalml/issues/285#issuecomment-762435858:

The sklearn.utils.testing module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.utils. Anything that cannot be imported from sklearn.utils is now part of the private API.

bellet commented 3 years ago

Indeed! We can also still import private functions from sklearn.utils._testing

We should however ensure back-compatibility with previous versions of sklearn (since we allow scikit-learn>=0.20.3). One option is to do something similar to https://github.com/uber/causalml/pull/283

wdevazelhes commented 3 years ago

Indeed! We can also still import private functions from sklearn.utils._testing

We should however ensure back-compatibility with previous versions of sklearn (since we allow scikit-learn>=0.20.3). One option is to do something similar to uber/causalml#283

Thanks for the reference @bellet, I just opened a PR to try fix the imports using this technique, and add the travis job to ensure it is indeed still back-compatible https://github.com/scikit-learn-contrib/metric-learn/pull/313