Skip to content

[SPARK-5015] [mllib] Random seed for GMM + make test suite deterministic #3981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

jkbradley
Copy link
Member

Issues:

  • From JIRA: GaussianMixtureEM uses randomness but does not take a random seed. It should take one as a parameter.
  • This also makes the test suite flaky since initialization can fail due to stochasticity.

Fix:

  • Add random seed
  • Use it in test suite

CC: @mengxr @tgaloppo

@jkbradley
Copy link
Member Author

Btw, in the docs, I did not say that the random seed is only used for initializing clusters since we may want to use it elsewhere in the future.

@mengxr
Copy link
Contributor

mengxr commented Jan 9, 2015

LGTM.

assert(gmm.weight(0) ~== Ew absTol 1E-5)
assert(gmm.mu(0) ~== Emu absTol 1E-5)
assert(gmm.sigma(0) ~== Esigma absTol 1E-5)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the single cluster case, I don't think the seed can make a difference. With only one cluster, this just makes sure the right mean and covariance are computed correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, you're correct. The issue is that, with some probability, the 5 data points chosen for initializing the cluster will be identical, causing initialization of the covariance matrix to fail.

I'd be fine with having this test use only 1 random seed instead of 5, but it's fast anyways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

@SparkQA
Copy link

SparkQA commented Jan 9, 2015

Test build #25333 has finished for PR 3981 at commit f0df4fd.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mengxr
Copy link
Contributor

mengxr commented Jan 9, 2015

Merged into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants