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

    https://github.com/apache/spark/pull/9838#discussion_r45350947
  
    --- Diff: mllib/src/test/scala/org/apache/spark/ml/feature/PCASuite.scala 
---
    @@ -65,4 +65,24 @@ class PCASuite extends SparkFunSuite with 
MLlibTestSparkContext {
             assert(x ~== y absTol 1e-5, "Transformed vector is different with 
expected vector.")
         }
       }
    +
    +  test("read/write") {
    +
    +    def checkModelData(model1: PCAModel, model2: PCAModel): Unit = {
    +      assert(model1.pc === model2.pc)
    +    }
    +    val allParams: Map[String, Any] = Map(
    +      "k" -> 3,
    +      "inputCol" -> "features",
    +      "outputCol" -> "pca_features"
    +    )
    +    val data = Seq(
    +      (0.0, Vectors.sparse(5, Seq((1, 1.0), (3, 7.0)))),
    +      (1.0, Vectors.dense(2.0, 0.0, 3.0, 4.0, 5.0)),
    +      (2.0, Vectors.dense(4.0, 0.0, 0.0, 6.0, 7.0))
    +    )
    +    val df = sqlContext.createDataFrame(data).toDF("id", "features")
    +    val pca = new PCA().setK(3)
    +    testEstimatorAndModelReadWrite(pca, df, allParams, checkModelData)
    +  }
     }
    --- End diff --
    
    The same as 
[StandardScalerModel](https://github.com/apache/spark/pull/9839/files#diff-7ae15fe7b1bc41e6a876c2424380d764R132),
 we can not construct PCAModel directly by specifying the variable ```k```, so 
test estimator and model in one case with ```testEstimatorAndModelReadWrite```.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to