Github user yanboliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/7694#discussion_r35959215
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/tree/impl/RandomForest.scala ---
@@ -620,29 +622,24 @@ private[ml] object RandomForest extends Logging {
}
}
- /**
- * Calculate the information gain for a given (feature, split) based
upon left/right aggregates.
- * @param leftImpurityCalculator left node aggregates for this (feature,
split)
- * @param rightImpurityCalculator right node aggregate for this
(feature, split)
- * @return information gain and statistics for split
- */
- private def calculateGainForSplit(
+ private def calculateImpurityStats(
leftImpurityCalculator: ImpurityCalculator,
rightImpurityCalculator: ImpurityCalculator,
- metadata: DecisionTreeMetadata,
- impurity: Double): InformationGainStats = {
+ metadata: DecisionTreeMetadata): ImpurityStats = {
val leftCount = leftImpurityCalculator.count
val rightCount = rightImpurityCalculator.count
+ val totalCount = leftCount + rightCount
+ val parentImpurityCalculator =
leftImpurityCalculator.copy.add(rightImpurityCalculator)
+ val impurity = parentImpurityCalculator.calculate()
--- End diff --
done
---
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.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]