zhengruifeng opened a new pull request, #58147: URL: https://github.com/apache/spark/pull/58147
### What changes were proposed in this pull request? This PR computes decision tree model stats in a single traversal of the root node. It adds `Node.computeStats`, which returns the subtree depth, number of descendants, and number of leaves. Decision tree classification and regression models compute these stats once and `DecisionTreeModel` reuses them for `numNodes`, `depth`, and leaf metadata. This also renames the package-private `numLeave` helper to `numLeaves`. ### Why are the changes needed? Before this change, decision tree model metadata could traverse the tree separately for depth, node count, and leaf count. Computing these values together avoids redundant tree walks. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Manually tested with: ``` git diff --check ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
