3

I am using gaussian mixture model in sklearn(python). A image is fitted on gaussian mixture model. Then, it will be clustered. (ex. component = 3, so some area is 0, and the others 1, 2) A tree area was 0, sky area was 1. But, I execute again, a tree area is 1. I don't understand why it is changed? Is there a way to fix the clustering??

Here are some codes.

gmm = GaussianMixture(n_components=3, covariance_type="tied")
gmm = gmm.fit(img)

cluster = gmm.predict(img)
cluster = cluster.reshape(old_shape[0], old_shape[1])

imshow(cluster)

data = np.array(cluster)
Sociopath
  • 13,068
  • 19
  • 47
  • 75
hohodduck
  • 33
  • 10
  • 2
    Just like kmeans initializes some random cluster centroids at first , gaussian mixture model also randomly initializes something called `responsibilities` to start from, so you won't get the some result each time you run. For your second question, you could use a fixed `random_state` to remove randomness and get exactly the same output each time you run. – Sacry Aug 29 '18 at 06:09
  • @Sacry Thanks a lot! I already read `sklearn.Gaussianmixture` manual. But, I did not understand `random_state` means. Now I know what it means. I also need to study more about the `Gaussian mixture model`. – hohodduck Aug 29 '18 at 10:50

0 Answers0