Why can't I import the AgglomerativeClustering class?

假装没事ソ 提交于 2019-12-13 07:12:34

问题


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 version

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2

OS info:

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-learn version

$ pip freeze | grep scikit-learn
scikit-learn==0.14.1

Further infos

>>> import sklearn.cluster; print(sklearn.cluster.__file__)
/usr/lib/python2.7/dist-packages/sklearn/cluster/__init__.pyc

回答1:


Looking at the changelog for version 0.15 it looks like the AgglomerativeClustering class was introduced in this version:

Changelog

New Features

[...]

  • Added cluster.AgglomerativeClustering for hierarchical agglomerative clustering with average linkage, complete linkage and ward strategies. [...]

So the only fix is to install a newer version of sklearn.



来源:https://stackoverflow.com/questions/32219881/why-cant-i-import-the-agglomerativeclustering-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!