我正在使用k-means聚类算法,并且对于每个聚类质心,我试图为质心生成n维Voronoi区域 . 之后我需要从Voronoi区域生成随机点 .
我已经尝试使用Matlab / Octave和scipy来获得n维Voronoi区域 . 但我有两个问题 .
生成顶点和区域后,如何从区域生成随机数据
如果聚类质心的数量小于n,则可以构造Voronoi区域,维数
编辑 -
我的主要目标是生成一个码本 . 我有60k的n维数据点,我想创建一个比如512个码字的码本,其中每个码字都是n维的 . 码本是原始数据的近似值 . 聚类将是这样做的一种方式 . 由于k-means需要很长时间,我想使用自适应迭代LBG(Shen Furao和Osamu Hasegawa),其过程是 -
找到具有最大错误的集群质心 - 让我们称之为C_large
在C_large的Voronoi区域生成一个随机点,让我们称之为C_new
使用voronoi区域中的数据点运行k-means,只有两个质心,C_large和C_new
这将比k-means快得多,因为每次使用总数据点的子集和仅两个质心运行k-means .
但是,算法以k = 1开始 . 但是直到k> n(数据是n维的)我才能使用scipy或Octave找到Voronoi区域 .
因此,如果我有一个单个质心,如C,则在Octave中运行voronoin(C)给我
error: voronoin: number of points must be greater than their dimension
那么有没有办法在这种情况下生成Voronoi区域 .
对于我的第二个问题,给出了一个很好的答案 .
我想问一下另一个相关的问题 . 由于Octave中的voronoin(C)不适用于C中的点数小于n(维数),我尝试运行简单的k-means 50次,得到50个聚类质心 . 然后,当我尝试运行voronoin(C),其中C是一个大小为50X36的矩阵,所以有50个聚类质心,每个都是36维点,我得到以下错误 -
qhull error (qh_memalloc): insufficient memory
While executing: | qhull v Qbb Qx
Options selected for Qhull 2009.1 2009/06/14:
voronoi Qbbound-last Qxact-merge _zero-centrum Pgood
Q3-no-merge-vertices-dim-high _max-width 1.6 Error-roundoff 9.4e-14
_one-merge 7.6e-12 _near-inside 3.8e-11 Visible-distance 5.6e-13
U-coplanar-distance 5.6e-13 Width-outside 1.1e-12 _wide-facet 3.4e-12
Last point added to hull was p23.
At error exit:
Voronoi diagram by the convex hull of 50 points in 40-d:
Number of Voronoi regions: 48
Total number of nearly incident points: 2
Number of Voronoi vertices: 0
Statistics for: | qhull v Qbb Qx
Number of points processed: 48
Number of hyperplanes created: 5070358
Number of facets in hull: 4320576
Number of distance tests for qhull: 1525377
error: voronoin: qhull failed
warning: voronoin: qhull did not free -2099969864 bytes of long memory (1 pieces)
我想我做错了什么,但我无法弄明白 . 我还查看了我可以提供的选项以及此处提供的voronoin()
但我似乎无法弄清楚他们是否会在这里帮助我
这是50个集群质心的链接
这是我正在运行的代码
C = dlmread('clust_centroids');
[Vc,Vf] = voronoin(C);
这给了我上面给出的错误 .