rasbt / mlxtend

A library of extension and helper modules for Python's data analysis and machine learning libraries.
https://rasbt.github.io/mlxtend/
Other
4.86k stars 857 forks source link

Tests fail with sklearn 0.24.1 because of deprecated imports #772

Closed rmcgibbo closed 3 years ago

rmcgibbo commented 3 years ago

Hello, quick friendly note:

I noticed on the NixOS continuous integration service, hydra, that the mlxtend tests fail to run with sklearn 0.24.1, the latest release (January 2021).

This is the error message:

==================================== ERRORS ====================================
________ ERROR collecting mlxtend/plotting/tests/test_pca_corr_graph.py ________
ImportError while importing test module '/build/source/mlxtend/plotting/tests/test_pca_corr_graph.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/fg7bbgshp0zadayr28yhsmrrivl500vi-python3-3.7.9/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
mlxtend/plotting/tests/test_pca_corr_graph.py:4: in <module>
    from sklearn.decomposition.pca import PCA
E   ModuleNotFoundError: No module named 'sklearn.decomposition.pca'

And here are the full log files: https://nix-cache.s3.amazonaws.com/log/3yyp38vdgk6jr62kf70zbvvln4crr0q3-python3.7-mlxtend-0.17.3.drv

In older versions of sklearn, I see this warning:

>>> import sklearn.decomposition.pca
/nix/store/ry8029wz0sm3lbr12p3hgv2xnwk5wvhs-python3-3.8.5-env/lib/python3.8/site-packages/sklearn/utils/deprecation.py:143: FutureWarning: The sklearn.decomposition.pca 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.decomposition. Anything that cannot be imported from sklearn.decomposition is now part of the private API.
  warnings.warn(message, FutureWarning)

so likely the imports just need to be tweaked a bit.

rasbt commented 3 years ago

Thanks! I will look into that. I think you are right, the imports need to be updated.

rasbt commented 3 years ago

I think this should be fixed in the current github version now.

rmcgibbo commented 3 years ago

@rasbt: Sorry to pile on, it looks like after fixing this there might still be a few more 0.24.1. incompatibilities around some other sklearn API changes. Here's the new log: https://gist.github.com/rmcgibbo/996510a6e0c0be859835891b7eeff86e

rasbt commented 3 years ago

I just see the reason why things passed in the previous PR is that apparently I was running out of Travis-CI credits and the new default seems to be skipping travis-ci tests. I probably need to find an alternative service for testing because travis-ci doesn't seem to be vialable for this project anymore. I will keep this open for now to revist

rasbt commented 3 years ago

My guess why this slipped through locally & appveyor is that sklearn 0.24.1 doesn't seem to be on the main conda channel yet. This should hopefully be fixed now via #774