Github user MechCoder commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4986#discussion_r26415328
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/mllib/clustering/GaussianMixtureSuite.scala
 ---
    @@ -138,4 +126,36 @@ class GaussianMixtureSuite extends FunSuite with 
MLlibTestSparkContext {
         assert(sparseGMM.gaussians(0).sigma ~== Esigma(0) absTol 1E-3)
         assert(sparseGMM.gaussians(1).sigma ~== Esigma(1) absTol 1E-3)
       }
    +
    +  test("model save / load") {
    +    val data = GaussianTestData.data
    +
    +    val gmm = new GaussianMixture().setK(2).setSeed(0).run(data)
    +    val tempDir = Utils.createTempDir()
    +    val path = tempDir.toURI.toString
    +
    +    try {
    +      gmm.save(sc, path)
    +      val sameModel = GaussianMixtureModel.load(sc, path)
    +      assert(sameModel.k === gmm.k)
    +      (0 until sameModel.k).foreach { i =>
    +        assert(sameModel.gaussians(i).mu === gmm.gaussians(i).mu)
    +        assert(sameModel.gaussians(i).sigma === gmm.gaussians(i).sigma)
    +      }
    +    } finally {
    +      Utils.deleteRecursively(tempDir)
    +    }
    +  }
    +
    +  object GaussianTestData {
    +
    +    val data = sc.parallelize(Array(
    --- End diff --
    
    How about just defining the Array of Vectors here and the `sc.parallelize` 
is done inside all functions independently?
    I did this just to avoid code repetition.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to