srowen commented on a change in pull request #25383: [SPARK-13677][ML] 
Implement Tree-Based Feature Transformation for ML
URL: https://github.com/apache/spark/pull/25383#discussion_r315710356
 
 

 ##########
 File path: 
mllib/src/test/scala/org/apache/spark/ml/classification/GBTClassifierSuite.scala
 ##########
 @@ -252,6 +249,26 @@ class GBTClassifierSuite extends MLTest with 
DefaultReadWriteTest {
     Utils.deleteRecursively(tempDir)
   }
 
+  test("model support predict leaf index") {
+    val model0 = new DecisionTreeRegressionModel("dtc", TreeTests.root0, 3)
+    val model1 = new DecisionTreeRegressionModel("dtc", TreeTests.root1, 3)
+    val model = new GBTClassificationModel("gbtc", Array(model0, model1), 
Array(1.0, 1.0), 3, 2)
+    model.setLeafCol("predictedLeafId")
+      .setRawPredictionCol("")
+      .setPredictionCol("")
+      .setProbabilityCol("")
+
+    val data = TreeTests.getTwoTreesLeafData
+    data.foreach { case (leafId, vec) => assert(leafId === 
model.predictLeaf(vec)) }
+
+    val df = sc.parallelize(data, 1).toDF("leafId", "features")
+    model.transform(df).select("leafId", "predictedLeafId")
+      .collect().foreach {
+      case Row(leafId: Vector, predictedLeafId: Vector) =>
 
 Review comment:
   Total nit, but this should indent further, or just pull the previous line 
onto the line 2 lines above. Same below.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to