You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/12/09 00:33:02 UTC

[GitHub] [spark] srowen commented on a change in pull request #26547: [SPARK-29914][ML] ML models attach metadata in `transform`/`transformSchema`

srowen commented on a change in pull request #26547: [SPARK-29914][ML] ML models attach metadata in `transform`/`transformSchema`
URL: https://github.com/apache/spark/pull/26547#discussion_r355228316
 
 

 ##########
 File path: mllib/src/test/scala/org/apache/spark/ml/util/MLTest.scala
 ##########
 @@ -64,6 +65,38 @@ trait MLTest extends StreamTest with TempDirectory { self: Suite =>
     }
   }
 
+  private[ml] def checkVectorSizeOnDF(
+      dataframe: DataFrame,
+      vecColName: String,
+      vecSize: Int): Unit = {
+    import dataframe.sparkSession.implicits._
+    val group = AttributeGroup.fromStructField(dataframe.schema(vecColName))
+    assert(group.size === vecSize,
+      s"the vector size obtained from schema should be $vecSize, but got ${group.size}")
+    val sizeUDF = udf { vector: Vector => vector.size }
+    assert(dataframe.select(sizeUDF(col(vecColName)))
+      .as[Int]
+      .collect()
+      .forall(_ === vecSize))
+  }
+
+  private[ml] def checkNominalOnDF(
+      dataframe: DataFrame,
+      colName: String,
+      numValues: Int): Unit = {
+    import dataframe.sparkSession.implicits._
+    val n = Attribute.fromStructField(dataframe.schema(colName)) match {
 
 Review comment:
   I think that's all the cases that need to be covered. The warning could be avoided by adding a case that throws an exception. That kind of cleanup is fine across the code. It won't matter too much here as it'll already generate an exception (correctly)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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