Yellowbrick visualiser.fit() 引发 ValueError

Posted

技术标签:

【中文标题】Yellowbrick visualiser.fit() 引发 ValueError【英文标题】:yellowbrick visualiser.fit() raises ValueError 【发布时间】:2019-07-31 23:59:23 【问题描述】:

我正在尝试为我的 twitter 数据可视化分散图

这里是数据集的链接

dataset

这是代码

from yellowbrick.text import DispersionPlot

text = combine['tweet']
target_words = ht_negative_unnest

visualizer = DispersionPlot(target_words)
visualizer.fit(text)
visualizer.poof()

我正在尝试在存储在 ht_negative_unnest 中的上述代码中传递这样的列表

 ['cnn',
     'michigan',
     'tcot',
     'australia',
     'opkillingbay']

引发的错误

 YellowbrickValueError                     Traceback (most recent call last)
<ipython-input-114-d6a94f150164> in <module>
      7 # Create the visualizer and draw the plot
      8 visualizer = DispersionPlot(target_words)
----> 9 visualizer.fit(text)
     10 visualizer.poof()

c:\users\hp\appdata\local\programs\python\python37\lib\site-packages\yellowbrick\text\dispersion.py in fit(self, X, y, **kwargs)
    171         self.target = points_target[:,2]
    172 
--> 173         self._check_missing_words(points)
    174 
    175         self.draw(points, self.target)

c:\users\hp\appdata\local\programs\python\python37\lib\site-packages\yellowbrick\text\dispersion.py in _check_missing_words(self, points)
    119                     "The indexed word '' is not found in "
    120                     "this corpus"
--> 121                     ).format(self.indexed_words_[index]))
    122 
    123     def fit(self, X, y=None, **kwargs):

YellowbrickValueError: The indexed word 'wso' is not found in this corpus

【问题讨论】:

您还有问题吗?我下面的回答有意义吗? 【参考方案1】:

我认为您的语料库中找不到wso;只有#wso

您是否尝试过像 ['love'] 这样的单一目标词?您仍然收到错误消息吗?

【讨论】:

您的意思是列表中的一个单词,因为列表中没有“wso”? @deepak-das ‘wso’ 在您的 target_words 列表中,但在文本中找不到 知道了。感谢您的帮助@larrywgray

以上是关于Yellowbrick visualiser.fit() 引发 ValueError的主要内容,如果未能解决你的问题,请参考以下文章

yellowbrick牛逼,机器学习“炼丹师”“调参侠”们有福了

ModuleNotFoundError 在 Python 中安装 Yellowbrick

更改 Yellowbrick 可视化颜色

python机器学习可视化工具Yellowbrick介绍及平行坐标图实战示例

提供的模型不是 YellowBrick 中的聚类估计器

Scikit-learn 和 Yellowbrick 给出不同的分数