[英]Imbalances-learn module base.py file syntax error coming up while importing SMOTE
I installed imbalanced-learn package using (Python 2.7):我使用(Python 2.7)安装了不平衡学习 package:
conda install -c conda-forge imbalanced-learn
after installing it, I tried to import SMOTE from the package.安装后,我尝试从 package 导入 SMOTE。
from imblearn.over_sampling import SMOTE
which gave the following error:这给出了以下错误:
File "C:\.conda\envs\py27\lib\site-packages\imblearn\base.py", line 21
class SamplerMixin(BaseEstimator, metaclass=ABCMeta):
^
SyntaxError: invalid syntax
can anybody help me in resolving this error or point out if I didn't install the package correctly?谁能帮我解决这个错误或指出我是否没有正确安装 package?
The version that has been installed by conda
is not compatible with Python 2 (I advise you to not use it since all datascience package stop to support it). conda
安装的版本不兼容 Python 2 (我建议你不要使用它,因为所有数据科学 package 都停止支持它)。
You can see it because the syntax to the metaclass should be written in the following manner in Python 2:您可以看到它,因为元类的语法应该在 Python 2 中以以下方式编写:
class SamplerMixin(BaseEstimator):
__metaclass__ = ABC
if I recall correctly如果我没记错的话
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.