AW: [R] Probleme with Kmeans...

TEMPL Matthias Matthias.Templ at statistik.gv.at
Tue May 11 16:40:00 CEST 2004


Sorry, to solve your question I had tried:

data(faithful)
kmeans(faithful[c(1:20),1],10)
Error: empty cluster: try a better set of initial centers

But when I run this a second time it will be ok.


It seems, that kmeans has problems to initialize good starting points, because of the random choose of these starting initial points.
With kmeans(data,k,centers=c(...) the problem can be solved.
Generally, the starting points can be choose equidistant on a hyperplane of the data, which is also a simple way to get the intitial points 
(www.fuzzyclustering.de , fc-package of Höppner, manual). 


Thank you for your comment,
Matthias


-----Ursprüngliche Nachricht-----
Von: Unung Istopo Hartanto [mailto:unung at enciety.com] 
Gesendet: Dienstag, 11. Mai 2004 16:23
An: TEMPL Matthias
Betreff: Re: [R] Probleme with Kmeans...


Hello Matthias,

I think kmeans able to process only one variable.

It's an example, but give me a clearly explanation if i make a mistake.

> univ
 [1] 0.7051308 0.9126754 0.6170866 0.6663761 5.8541014 0.6665355 0.9695508  [8] 1.1980253 0.9489970 0.9058717 4.0864110 0.9962518 0.7530303 1.0312622 [15] 5.0822132 3.1867548 2.3203937 0.5405755 3.6957646 0.8957396 0.8477315 [22] 0.6210427 0.8471373 3.5451798 0.4220632 0.5377178 0.3173005 0.7181018 [29] 0.9034660 1.2406042 0.9529861 3.3889001 0.8462411 0.8338748 1.8540691 [36] 1.3624104 6.9509700

> kmeans(univ,ncl)
$cluster
 [1] 5 3 5 5 4 5 3 3 3 3 1 3 5 3 4 1 2 5 1 3 3 5 3 1 5 5 5 5 3 3 3 1 3 3 2 3 4

$centers
       [,1]
1 3.5806021
2 2.0872314
3 0.9808016
4 5.9624282
5 0.5968146

$withinss
[1] 0.4622251 0.1087293 0.3637454 1.7637280 0.1768656

$size
[1]  5  2 16  3 11

Thanks a lot,

Unung Istopo

On Tue, 2004-05-11 at 17:19, TEMPL Matthias wrote:
> Hello,
> When clustering with kmeans, your data should have more than one 
> variable. Matthias




More information about the R-help mailing list