mlampros / ClusterR

Gaussian mixture models, k-means, mini-batch-kmeans and k-medoids clustering
https://mlampros.github.io/ClusterR/
84 stars 29 forks source link

resetting seed at every call of GMM? #21

Closed ericsc7 closed 4 years ago

ericsc7 commented 4 years ago

Dear mlampros, I am currently greatly benefiting from ClusterR via the Spectrum package! However, during an analysis I think I might have stumbled on an undesirable property. When running

library(Spectrum)
for(zi in 1:5){
  print(zi)
  print(rnorm(10,0,1))
  sc <- Spectrum(circles, maxk = 5)
}

After the second run, I keep getting as output for zi [1] -0.8356286 1.5952808 0.3295078 -0.8204684 0.4874291 0.7383247 0.5757814 -0.3053884 1.5117812 0.3898432 I am wondering whether this may be due to how the GMM function (which is called in Spectrum) is defined:

GMM = function(data, gaussian_comps = 1, dist_mode = 'eucl_dist', seed_mode = 'random_subset', km_iter = 10, em_iter = 5, verbose = FALSE, var_floor = 1e-10, seed = 1) Thus each run of Spectrum, or GMM, seems to reset the seed, which might lead to some unintended behaviour.

Thank you very much. Best, Eric

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.63. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

mlampros commented 4 years ago

Hi @ericsc7 and I'm sorry for the late reply,

I took a look to the code of the Spectrum package package and the ClusterR::GMM() function is called in 3 places (here, here and here). It seems that in all 3 cases the default seed of 1 is used, therefore I would expect (at least) what the ClusterR::GMM() code concerns that you would receive the same output if the function is run repeatedly.

stale[bot] commented 4 years ago

This is Robo-lampros because the Human-lampros is lazy. This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs. Feel free to re-open a closed issue and the Human-lampros will respond.