python - NLPlot 同现网络可视化返回
问题描述
我正在使用以下 NLPlot 来可视化单词共现网络。我尝试以下代码:
import nlplot
npt = nlplot.NLPlot(df, target_col='text')
stopwords = npt.get_stopword(top_n=30, min_freq=0)
npt.build_graph(stopwords=stopwords, min_edge_frequency=10)
npt.co_network(title='Co-occurrence network')
但它返回一个 IndexError 和 NetworkXError。我将我的装饰器降级到 4.3.0 但仍然无法正常工作。知道是什么导致了问题以及如何解决吗?
我也愿意接受其他执行相同可视化的 Python 包的建议。
谢谢
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\networkx\utils\decorators.py in _random_state(func, *args, **kwargs)
456 try:
--> 457 random_state_arg = args[random_state_index]
458 except TypeError as e:
IndexError: tuple index out of range
The above exception was the direct cause of the following exception:
NetworkXError Traceback (most recent call last)
<ipython-input-99-4563e2cacbef> in <module>
----> 1 npt.build_graph(stopwords=stopwords, min_edge_frequency=10)
2
3 # npt.co_network(title='Co-occurrence network')
~\Anaconda3\lib\site-packages\nlplot\nlplot.py in build_graph(self, stopwords, min_edge_frequency)
491 self.G = self.get_graph()
492 self.adjacencies = dict(self.G.adjacency())
--> 493 self.betweeness = nx.betweenness_centrality(self.G)
494 self.clustering_coeff = nx.clustering(self.G)
495 self.node_df.loc[:, 'adjacency_frequency'] = self.node_df['id_code'].map(lambda x: len(self.adjacencies[x]))
~\Anaconda3\lib\site-packages\decorator.py in fun(*args, **kw)
229 func, "return _call_(_func_, %s%%(shortsignature)s)" % es,
230 evaldict, __wrapped__=func)
--> 231 if hasattr(func, '__qualname__'):
232 fun.__qualname__ = func.__qualname__
233 return fun
~\Anaconda3\lib\site-packages\networkx\utils\decorators.py in _random_state(func, *args, **kwargs)
459 raise nx.NetworkXError("random_state_index must be an integer") from e
460 except IndexError as e:
--> 461 raise nx.NetworkXError("random_state_index is incorrect") from e
462
463 # Create a numpy.random.RandomState instance
NetworkXError: random_state_index is incorrect
解决方案
推荐阅读
- sql-server - 编辑 ADO 记录集而不更改数据库
- eclipse - 无法使用 apache-maven-3.3.3 和 JDK1.8.0_66 创建 Maven 项目
- javascript - 为什么我的变量在 forEach() 中不可访问?
- javascript - xBIM 查看器:从画布创建屏幕截图
- jquery - 将“活动”类添加到 PanelSnap 面板
- sql-server - 如何从整数类型的列中查找字符串数据?
- django - django 的数据表推荐
- odoo - 如何删除操作菜单odoo 11中的元素
- python - 将 kaggle 安装在错误的目录中
- c# - 通过脚本将多种材质分配给游戏对象?