Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/2332#discussion_r17321563
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala ---
@@ -803,11 +830,16 @@ object DecisionTree extends Serializable with Logging
{
val leftChildStats =
binAggregates.getImpurityCalculator(nodeFeatureOffset, splitIdx)
val rightChildStats =
binAggregates.getImpurityCalculator(nodeFeatureOffset, numSplits)
rightChildStats.subtract(leftChildStats)
+ predict =
Some(predict.getOrElse(calculatePredict(leftChildStats, rightChildStats)))
val gainStats =
calculateGainForSplit(leftChildStats, rightChildStats,
nodeImpurity, level, metadata)
(splitIdx, gainStats)
}.maxBy(_._2.gain)
- (splits(featureIndex)(bestFeatureSplitIndex), bestFeatureGainStats)
+ if (bestFeatureGainStats ==
InformationGainStats.invalidInformationGainStats) {
--- End diff --
I think you could avoid explicitly checking for invalidInformationGainStats
since the gain is Double.minValue. At the very end of the maxBy calls, you
could then check to see if the information gain is Double.minValue, in which
case we know that no split is worth doing. That should simplify the code here
and in the other maxBy calls below.
---
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]