izmailovpavel / understandingbdl

Other
229 stars 38 forks source link

latest sklearn has "sklearn.decomposition.pca import _assess_dimension_" removed #12

Open petteriTeikari opened 3 years ago

petteriTeikari commented 3 years ago

Hi,

Thanks for the interesting paper and code!

Not sure if really an issue in the repo, but maybe others will face this when trying to integrate SWAG with their existing code base, as I had conflicts with the downgrade of sklearn as that:

from sklearn.decomposition.pca import _assess_dimension_

had been removed from the recent sklearn 0.24.2 that I had in my project, and replaced by:

from sklearn.decomposition import PCA

and I am now trying to figure how to get the _assess_dimension_ to work

from src.externalCode.understandingbdl.swag.posteriors import SWAG
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "understandingbdl/swag/__init__.py", line 3, in <module>
    from . import (
  File "pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "understandingbdl/swag/posteriors/__init__.py", line 3, in <module>
    from .swag import SWAG
  File "pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "understandingbdl/swag/posteriors/swag.py", line 4, in <module>
    from .subspaces import Subspace
  File "pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "understandingbdl/swag/posteriors/subspaces.py", line 14, in <module>
    from sklearn.decomposition.pca import _assess_dimension_ # for older sklearn version from original repo
  File "pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'sklearn.decomposition.pca'
izmailovpavel commented 3 years ago

Hey @petteriTeikari thank you for pointing this out, I ran into this issue myself. In this project, we don't really _assess_dimension_ in this work, I believe it has been added to the codebase when we were working on https://arxiv.org/abs/1907.07504. I think you can safely comment out this import unless you are planning to use this module?

petteriTeikari commented 3 years ago

Hey @izmailovpavel , yeah I commented it away and got away with it, but thought of letting you know if you ever update the code :)