我目前正在学习K-means,所以现在我正在用Python编写一个程序来确定彼此相似的不同文本簇
现在我得到了两个不同聚类的结果(使用了一些虚构的词,但其他的都是一样的)
print(dfs) = [ features score
0 America 0.577350
1 new 0.288675
2 president 0.288675
3 Biden 0.288675
, features score
0 Corona 0.593578
1 COVID-19 0.296789
2 research 0.296789
3 health 0.158114]
dfs是以下类型
type(dfs) = list
以及以下各项:
type(dfs[0]) = pandas.core.frame.DataFrame
但是我如何为dfs中的每个集群创建条形图,在这些集群中,您可以看到每个单词的分数
提前谢谢
迭代} 函数的参数,从条形图轴迭代每个面片
dfs
列表以访问各个数据帧,然后使用df.plot.bar
和x='features
和y='score'
作为参数来绘制相对于同一数据帧的条形图。使用结果轴from plot函数将每个条的分数附加到features
列中。为此,使用矩形定位点的x
和条形图的height
作为^{相关问题 更多 >
编程相关推荐