johannfaouzi / pyts

A Python package for time series classification
https://pyts.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.77k stars 165 forks source link

ImportError: cannot import name 'PowerTransformer' #26

Closed bingyue0610 closed 5 years ago

bingyue0610 commented 5 years ago

Description

Steps/Code to Reproduce

<< 
from pyts.image import mtf

Traceback (most recent call last):
  File "C:\Users\BBD\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2963, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-33-02178b70bcc1>", line 1, in <module>
    from pyts.image import mtf
  File "E:\pycharm\PyCharm 2018.3.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\BBD\Anaconda3\lib\site-packages\pyts\image\__init__.py", line 6, in <module>
    from .gaf import GramianAngularField
  File "E:\pycharm\PyCharm 2018.3.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\BBD\Anaconda3\lib\site-packages\pyts\image\gaf.py", line 8, in <module>
    from ..approximation import PiecewiseAggregateApproximation
  File "E:\pycharm\PyCharm 2018.3.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\BBD\Anaconda3\lib\site-packages\pyts\approximation\__init__.py", line 4, in <module>
    from .sax import SymbolicAggregateApproximation
  File "E:\pycharm\PyCharm 2018.3.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\BBD\Anaconda3\lib\site-packages\pyts\approximation\sax.py", line 6, in <module>
    from ..preprocessing import KBinsDiscretizer
  File "E:\pycharm\PyCharm 2018.3.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\BBD\Anaconda3\lib\site-packages\pyts\preprocessing\__init__.py", line 4, in <module>
    from .transformer import PowerTransformer, QuantileTransformer
  File "E:\pycharm\PyCharm 2018.3.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\BBD\Anaconda3\lib\site-packages\pyts\preprocessing\transformer.py", line 4, in <module>
    from sklearn.preprocessing import PowerTransformer as SklearnPowerTransformer
ImportError: cannot import name 'PowerTransformer'

>>

Versions

bingyue0610 commented 5 years ago

It has been resolved! Thank you!

Erwachen6 commented 1 year ago

It has been resolved! Thank you! Can I know how you solved it? I'm also getting this error now.

johannfaouzi commented 1 year ago

Hi,

scikit-learn is a dependency of the package and is installed when you install pyts. sklearn.preprocessing.PowerTransformer has been added in scikit-learn==0.20 and pyts requires scikit-learn>=0.22, so it should be available.

Can you please give the versions of the these packages?

import pyts; print("pyts", pyts.__version__)
import sklearn; print("scikit-learn", sklearn.__version__)
Erwachen6 commented 1 year ago

Thank you! I have resolve it!

------------------ 原始邮件 ------------------ 发件人: "johannfaouzi/pyts" @.>; 发送时间: 2022年12月5日(星期一) 下午5:54 @.>; @.**@.>; 主题: Re: [johannfaouzi/pyts] ImportError: cannot import name 'PowerTransformer' (#26)

Hi,

scikit-learn is a dependency of the package and is installed when you install pyts. sklearn.preprocessing.PowerTransformer has been added in scikit-learn==0.20 and pyts requires scikit-learn>=0.22, so it should be available.

Can you please give the versions of the these packages? import pyts; print("pyts", pyts.version) import sklearn; print("scikit-learn", sklearn.version)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>