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/08/10 08:25:45 UTC

[GitHub] [spark] mgaido91 commented on a change in pull request #25383: [SPARK-13677][ML] Implement Tree-Based Feature Transformation for ML

mgaido91 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_r312695424
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/tree/treeModels.scala
 ##########
 @@ -78,6 +78,28 @@ private[spark] trait DecisionTreeModel {
 
   /** Convert to spark.mllib DecisionTreeModel (losing some information) */
   private[spark] def toOld: OldDecisionTreeModel
+
+  /** Returns an iterator that traverses (DFS, left to right) the leaves
+   *  in the subtree of this node.
+   */
+  private def leafIterator(node: Node): Iterator[LeafNode] = {
+    node match {
+      case l: LeafNode => Iterator.single(l)
+      case n: InternalNode =>
+        leafIterator(n.leftChild) ++ leafIterator(n.rightChild)
+    }
+  }
+
+  @transient private lazy val leafIndices: Map[LeafNode, Int] = {
 
 Review comment:
   I am a bit worried by the extra memory pressure caused by this, in case trees are big.... can't we rather assign an index to the `LeafNode` class?

----------------------------------------------------------------
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