本文介绍了为什么不能导入AgglomerativeClustering类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 AgglomerativeClustering 来自sklearn,但我无法导入它.
I would like to use AgglomerativeClustering from sklearn but I am not able to import it.
>>> from sklearn.cluster import AgglomerativeClustering
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name AgglomerativeClustering
该消息没有提供导致问题的原因的太多信息,您能帮忙吗?
The message dosen't give much information on what's causing the issue, can you help?
Python版本
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
操作系统信息:
3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Scikit学习版本
Scikit-learn version
$ pip freeze | grep scikit-learn
scikit-learn==0.14.1
更多信息
>>> import sklearn.cluster; print(sklearn.cluster.__file__)
/usr/lib/python2.7/dist-packages/sklearn/cluster/__init__.pyc
推荐答案
查看版本0.15的更改日志,似乎在此版本中引入了AgglomerativeClustering
类:
Looking at the changelog for version 0.15 it looks like the AgglomerativeClustering
class was introduced in this version:
- 添加了
cluster.AgglomerativeClustering
用于具有平均链接,完全链接和 病房策略. [...]
- Added
cluster.AgglomerativeClustering
for hierarchical agglomerative clustering with average linkage, complete linkage and ward strategies. [...]
因此,唯一的解决方法是安装更新版本的sklearn
.
So the only fix is to install a newer version of sklearn
.
这篇关于为什么不能导入AgglomerativeClustering类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!