zhengruifeng 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_r314254595
########## 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: yes, this var is only generated when needed. and I make it transient, so it don't cause extra network/storage overhead. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org