[R] Empty clusters in k-means - possible solution
maitra.mbox.ignored at inbox.com
Sun May 19 18:18:43 CEST 2013
There is a documented bug in R 2.15.2 and R 2.15.3. The developers
decided not to fix this with an update, but it has been fixed with R
3.0.0 (perhaps also with R 3.0.1, which I have not tried myself). So,
upgrading R should take care of this problem.
On Sun, 19 May 2013 16:17:30 +0200 Luca Nanetti
<luca.nanetti at gmail.com> wrote:
> Dear Simon,
> I respectfully disagree with you, when you say that it is NOT a bug. Empty
> clusters can only happen if one provides a set of centers; if one enters
> something like k=4, it cannot happen, so it must be a bug. Which one is
> your case?
> >From the help:
> "Except for the Lloyd-Forgy method, k clusters will always be returned if a
> number is specified. If an initial matrix of centres is supplied, it is
> possible that no point will be closest to one or more centres, which is
> currently an error for the Hartigan-Wong method"
> This having been said, I suspect that there is a bug in the current
> implementation of kmeans. I get the "empty cluster: try ..." answer even
> when I enter a number of clusters, but only with R 2.15. I never had it
> with R 2.14. Didn't try with R 3, yet.
> I posted this problem on the list twice, at no avail (unless I forgot to
> find the answer in the mailing list, of course).
> Kind regards,
> > Hello all,
> > k-means algorithms can at times fail because one of the cluster become
> > emmpty. In this case, the kmeans R function returns:
> >"empty cluster: try a better set of initial centers"
> > This has been discussed several times on several R-lists, and is NOT a
> > bug, but can be annoying when using k-means in complex simulation where
> > this error brings everything to a stop. One can use try() or tryCatch()
> > to avoid this, but this is just a programming trick.
> Luca Nanetti, MSc, MRI
> University Medical Center Groningen
> Neuroimaging Center Groningen
> Groningen, The Netherlands
> Tel: +31 50 363 4733
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Important Notice: This mailbox is ignored: e-mails are set to be
deleted on receipt. For those needing to send personal or professional
e-mail, please use appropriate addresses.
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help