首页 > 解决方案 > ImportError:无法从“sklearn.feature_extraction.text”导入名称“countVectorizer”

问题描述

代码

import numpy as np
from sklearn.feature_extraction.text import countVectorizer
count=countVectorizer
docs=np.array(['The sun is shinning',
               'The weather is sweet',
               'The sun is shinning,The weather is sweet, and one and one is two'])
bag= count.fit_transform(docs)

错误输出

ImportError                               Traceback (most recent call last)
<ipython-input-1-e322748c3b4c> in <module>
      1 import numpy as np
----> 2 from sklearn.feature_extraction.text import countVectorizer
      3 count=countVectorizer
      4 docs=np.array(['The sun is shinning',
      5                'The weather is sweet',

ImportError: cannot import name 'countVectorizer' from 'sklearn.feature_extraction.text' (C:\ProgramData\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py)

声明 我收到此错误帮助我解决它。我在 anaconda 导航器提示符中使用 jupyter notebook。我安装了最新版本的 scikit-learn 但我也遇到了相同的导入错误。然后还使用 Anaconda 命令提示符安装和卸载了 scikit-learn

标签: pythonscikit-learncountvectorizer

解决方案


从 sklearn.feature_extraction.text 导入 CountVectorizer

正在工作中


推荐阅读