首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在python中使用hcluster进行层次聚类时出错

在python中使用hcluster进行层次聚类时出错
EN

Stack Overflow用户
提问于 2013-10-23 20:09:08
回答 1查看 361关注 0票数 0

我正在尝试运行以下代码,并得到一个AttributeError:'module‘对象没有'hcluster’属性,这是在最后一行中引发的。

我在Mountain Lion中运行,我使用pip和homebrew,而hcluster在PYTHONPATH=/usr/local/lib/python2.7/site-packages.中

你知道会出什么问题吗?谢谢。

代码语言:javascript
复制
import os 
import hcluster
from numpy import *
from PIL import Image
# create a list of images
path = 'data/flickr-sunsets-small'
imlist = [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.jpg')]
# extract feature vector (8 bins per color channel)
features = zeros([len(imlist), 512])
for i,f in enumerate(imlist):
    im = array(Image.open(f))
    # multi-dimensional histogram
    h,edges = histogramdd(im.reshape(-1,3),8,normed=True,range=[(0,255),(0,255),(0,255)]) 
    features[i] = h.flatten()
tree = hcluster.hcluster(features)
EN

回答 1

Stack Overflow用户

发布于 2013-10-23 21:59:24

这个错误意味着Python无法在模块hcluster中找到函数/类hcluster,所以当您执行tree = hcluster.hcluster(features)操作时,它会报错。

我不熟悉这个模块,但我快速浏览了一下,它列出了一个名为fcluster的函数,但没有hcluster

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19541270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档