Cannot run pyLDAvis. Getting Error : ImportError: cannot import name PCoA

Cannot run pyLDAvis. Getting Error : ImportError: cannot import name PCoA

我已经使用 gensim 创建了 LDA 模型。现在,我想使用 pyLDAvis 库将其可视化,但得到:

ImportError: cannot import name PCoA 

任何人都可以帮助我解决这个问题或提出一些替代方案。

提前致谢。

您必须检查 scikit-bio python 包。它必须小于 0.4.x。从版本 0.4.x 开始,该方法具有不同的名称。

您必须按以下方式安装正确的版本:

sudo pip install scikit-bio==0.2.X

干杯

此函数的名称从 scikit-bio 的 0.2.x (alpha) 分支更改为 0.4.x (beta) 分支。您可以通过安装 scikit-bio 0.2.3 使用旧名称的函数,或者修改您的代码以使用新函数名称。我推荐后者,因为此界面正在稳定,因此现在进行更改将使您能够继续访问最新功能。

更新您对 0.4.1 的 PCoA 调用涉及两部分。您需要调整您的导入和函数调用以使用新名称(pcoa - 现在全部小写,请参阅 changelog note on this here),然后更改您与结果的交互方式,因为 OrdinationResults 对象在这些版本之间得到了改进。首先,您的导入现在应该如下所示:

from skbio.stats.ordination import pcoa

然后,您可以查看changelog description of what's changed with the OrdinationResults object here

如果您只想坚持使用 0.2.3,则以下任一方法都适用于安装:

pip install scikit-bio==0.2.3
conda install scikit-bio==0.2.3

在相关说明中,请参阅我们的 API stability docs 了解如何了解 scikit-bio 中的 stable/experimental/deprecated 功能。