0
$\begingroup$

How can I calculate the probability of membership with R's kmeans output?

The output of kmeans is as follows:

k <- kmeans(iris[-5], 3)
str(k)
# List of 9
# $ cluster     : int [1:150] 2 3 3 3 2 2 2 2 3 3 ...
# $ centers     : num [1:3, 1:4] 6.31 5.18 4.74 2.9 3.62 ...
# ..- attr(*, "dimnames")=List of 2
# .. ..$ : chr [1:3] "1" "2" "3"
# .. ..$ : chr [1:4] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width"
# $ totss       : num 681
# $ withinss    : num [1:3] 118.65 6.43 17.67
# $ tot.withinss: num 143
# $ betweenss   : num 539
# $ size        : int [1:3] 96 33 21
# $ iter        : int 2
# $ ifault      : int 0
# - attr(*, "class")= chr "kmeans"

Is this enough information to copy what we get from Mclust?

library(mclust)
m <- Mclust(iris[-5])
head(m$z)
#           [,1]         [,2]
# [1,] 1.0000000 2.513157e-11
# [2,] 0.9999999 5.556411e-08
# [3,] 1.0000000 3.635438e-09
# [4,] 0.9999999 8.611811e-08
# [5,] 1.0000000 8.504494e-12
# [6,] 1.0000000 1.400364e-12

Obvious question is "Why not use mclust?". My data is too large to computationally do hierarchical clustering. I have tried with Mclust, NbClust, vegan, and many others. The call to dist that all of the functions use max out after a few hundred thousand rows.

I have seen some talk about probabilistic-D, and "soft" clustering, but I do not know how to implement it without changing the output of the original clusters from kmeans.

Edit I know that SAS is able to export probabilities with PROC FASTCLUS, but from what I hear it is taking a sample of the data to get the probabilities. That might be one route to take if I could figure out how it's doing the subsetting.

$\endgroup$
3
  • $\begingroup$ stackoverflow.com/a/2346069 $\endgroup$ Commented May 18, 2016 at 19:03
  • $\begingroup$ I'll try e1071::cmeans based on the link, and check back, thank you $\endgroup$
    – Pierre L
    Commented May 18, 2016 at 19:15
  • $\begingroup$ if you find something useful and are able to answer your question, I'd encourage you to post the solution as an answer to your own question. It will be helpful to others in the future $\endgroup$ Commented May 18, 2016 at 20:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.