[R] GETTING CLUSTERING RESULTS IN SOM , LIKE K-MEAN

Sarah Goslee sarah.goslee at gmail.com
Sat May 24 19:58:25 CEST 2014


Based on the example in ?som (did you work through that and look at
the various outputs?), you need to use som.prediction() to get the
predicted class values.

Sarah

On Sat, May 24, 2014 at 1:28 AM, Ashis Deb <ashisdeb83 at gmail.com> wrote:
> Hi   all    ,
>
>
>                  I  was  doing    k-mean  clustering    through  which   i
> could  find  out   each  and  every  clusters  and  the  contents
> around    each  cluster   centroid   like    below  :-
>
>
> x<-read.csv("normalizedata.csv", header = TRUE)    #To read the dataset
>
> km<- kmeans(x, 3, 150)
>
> print(km)    <<<----   in  this   I   could   get   every  clusters  and
> centroids  .
>
> km$cluster    <<-----  It   gave    me   the   clusters   which   comes
> up   during   clustering  like
>
>
>
>
>
>  [1] 3 3 1 2 3 2 1 2 1 3 2 1 3 1 1 1 3 2 1 1 1 1 3 1 1 2 2 2 1 3 3 1 3 3 2
> 2 2
>  [38] 3 1 3 1 3 3 1 1 1 3 1 1 2 1 3 3 3 3 3 3 3 3 3 3 1 3 2 3 2 2 3 3 3 3 2
> 3 2
>  [75] 1 2 2 1 1 3 3 1 3 1 1 1 1 3 3 2 1 3 3 3 1 3 1 1 1 1 1 2 1 3 1 1 1 2 1
> 3 3
> [112] 1 3 1 2 1 1 1 1 1 1 1 2 2 1 3 1 2 3 1 1 3 2 1 1 1 2 1 3 2 1 3 1 1 1 3
> 2 1
> [149] 3 2 3 3 3 3 1 2 1 1 1 1 1 1 3 2 2 2 1 1 1 3 3 1 1 3 2 1 3 1 1 1 1 1 2
> 1 1
> [186] 3 1 2 1 3 2 3 2 1 2 1 2 3 1 1 1 2 3 2 1 1 2 3 3 1 2 2 1 3 1 1 2 3 3 1
> 1 3
> [223] 3 1 1 3 3 3 2 2 1 3 3 3 2 2 1 2 3 1 1 2 1 1 1 1 1 3 1 3 2 1 1 3 1 1 2
> 2 3
> [260] 1 3 3 3 1 1 2 1 3 1 3 1 2 1 1 1 3 3 2 3 1 1 1 2 1 3 3 1 3 3 1 1 2 1 2
> 3 3
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> But  in  case  of  SOM   clustering   when  i  had  tried    like    :-
>
>
>
> require(kohonen)
> require (som)    #To load Kohonen Package
>
> x<-read.csv("normalizedata.csv",header=TRUE)
>
> x.sc <- scale(x)    #To scale
>
> set.seed(7)
>
> xx.som<- SOM(data = x.sc, grid = somgrid(1, 3, "hexagonal"))    #som
> function
>
>
>
>
> print(xx.som)
>
>
> I  got  :-
>
>
>
>
>
>
>
>
> $codes
>         hrefCount Number.of.times.Visited Total.time.Spent
> [1,] -0.008926424              0.01642686      -0.01059301
> [2,] -0.008926424              0.01642686      -0.01059301
> [3,] -0.023231402             -0.06730921      -0.02705149
>
>
>
> I  hope  this  are  the   centroids  ,   I need   the  cluster    results
> like  kmeans   ,  how  to  achieve   it   ,  can  any  one    helps .
>
>
>
> THanks
>
> ASHIS
>
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list