Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/1673#discussion_r15628197
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala ---
@@ -815,20 +822,10 @@ object DecisionTree extends Serializable with Logging
{
topImpurity: Double): InformationGainStats = {
strategy.algo match {
case Classification =>
- var classIndex = 0
- val leftCounts: Array[Double] = new Array[Double](numClasses)
- val rightCounts: Array[Double] = new Array[Double](numClasses)
- var leftTotalCount = 0.0
- var rightTotalCount = 0.0
- while (classIndex < numClasses) {
- val leftClassCount =
leftNodeAgg(featureIndex)(splitIndex)(classIndex)
- val rightClassCount =
rightNodeAgg(featureIndex)(splitIndex)(classIndex)
- leftCounts(classIndex) = leftClassCount
- leftTotalCount += leftClassCount
- rightCounts(classIndex) = rightClassCount
- rightTotalCount += rightClassCount
- classIndex += 1
- }
+ val leftCounts: Array[Double] =
leftNodeAgg(featureIndex)(splitIndex)
+ val rightCounts: Array[Double] =
rightNodeAgg(featureIndex)(splitIndex)
+ var leftTotalCount = leftCounts.sum
+ var rightTotalCount = rightCounts.sum
--- End diff --
Those two values could be `val`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---