[SciPy-user] Mysterious kmeans() error

josef.pktd@gmai... josef.pktd@gmai...
Wed Feb 4 11:44:27 CST 2009


On Wed, Feb 4, 2009 at 12:28 PM, Roy H. Han
<starsareblueandfaraway@gmail.com> wrote:
> As a side comment, if I use Pycluster, then the clustering proceeds
> without error.
>
> On Wed, Feb 4, 2009 at 11:31 AM, Roy H. Han
> <starsareblueandfaraway@gmail.com> wrote:
>> Has anyone seen this error before?  I have no idea what it means.  I'm
>> using version 0.6.0 packaged for Fedora.
>> I'm getting this error using the kmeans2() implementation in scipy.cluster.vq
>>
>>
>>  File "/mnt/windows/svn/networkPlanner/acquisition/libraries/probability_process.py",
>> line 55, in grapeCluster
>>    assignments = scipy.cluster.vq.kmeans2(globalCluster, k=2,
>> iter=iterationCountPerBurst)[1]
>>  File "/usr/lib64/python2.5/site-packages/scipy/cluster/vq.py", line
>> 563, in kmeans2
>>    clusters = init(data, k)
>>  File "/usr/lib64/python2.5/site-packages/scipy/cluster/vq.py", line
>> 469, in _krandinit
>>    x = N.dot(x, N.linalg.cholesky(cov).T) + mu
>>  File "/usr/lib64/python2.5/site-packages/numpy/linalg/linalg.py",
>> line 418, in cholesky
>>    Cholesky decomposition cannot be computed'
>> numpy.linalg.linalg.LinAlgError: Matrix is not positive definite -
>>    Cholesky decomposition cannot be computed

This is just a general answer, I never used scipy.cluster

The error message means that the covariance matrix of your
np.cov(data)  is not positive definite. Check your data, whether there
is any linear dependence, eg. look at eigenvalues of np.cov(data).

If that's not the source of the error, then a cluster expert is needed.

Josef

>>
>>
>> Thanks,
>> RHH
>>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-user mailing list