Uh oh!
There was an error while loading. Please reload this page.
[SPARK-14610][ML] Remove superfluous split for continuous features in decision tree training - #12374
[SPARK-14610][ML] Remove superfluous split for continuous features in decision tree training#12374sethah wants to merge 9 commits into
Conversation
sethah
commented
Apr 13, 2016
cc @jkbradley This is a small PR that generally makes things more correct. But, I realize that this did not really have any adverse effects before, so I'll understand if this does not get merged. It is likely to be more of a problem when working on micro datasets. Although, there is a small change I included which I do think is incorrect and should be fixed, regarding how |
There was a problem hiding this comment.
The number of possible bins should be valueCounts.length, and the number of possible splits should therefore be valueCounts.length - 1.
SparkQA
commented
Apr 14, 2016
Test build #55765 has finished for PR 12374 at commit
|
SparkQA
commented
Apr 14, 2016
Test build #55768 has finished for PR 12374 at commit
|
SparkQA
commented
May 23, 2016
Test build #59138 has finished for PR 12374 at commit
|
sethah
commented
Jun 21, 2016
cc @MechCoder@MLnick Could you take a look? |
There was a problem hiding this comment.
This test would have failed before due to the assertion that splits.length > 0.
There was a problem hiding this comment.
"train with constant features" -> "train with constant continuous features"?
There was a problem hiding this comment.
This test is not specific to continuous features.
SparkQA
commented
Jun 21, 2016
Test build #60975 has finished for PR 12374 at commit
|
SparkQA
commented
Jun 22, 2016
Test build #60979 has finished for PR 12374 at commit
|
There was a problem hiding this comment.
This seems slightly hacky to me. What is your opinion about doing filtering out the feature indices that have zero splits (something similar to this)?
valvalidFeaturesSplits=Range(0, binAggregates.metadata.numFeaturesPerNode).filter { featureIndexIdx =>valfeatureIndex=if (featuresForNode.nonEmpty) {
featuresForNode.get.apply(featureIndexIdx)
} else {
featureIndexIdx
}
binAggregates.metadata.numSplits(featureIndex) !=0
}That will prevent code-rewrite for this corner-case in PR's such as #13959 and #8540
There was a problem hiding this comment.
I agree. I modified your suggestion to work with a view, so we don't allocate unnecessary memory.
MechCoder
commented
Jul 6, 2016
@sethah Nice catch! This superfluous split seems to be only for continuous features in which the number of unique values - 1 is lesser than or equal to the number of splits. Can you update the PR title or description to reflect this change? Thanks! |
There was a problem hiding this comment.
Why is the impurity of the rootNode "-1"? Since there is only one class and no splits should it not be just zero?
There was a problem hiding this comment.
No, since the node found no valid split we flag the impurity as invalid. See here
MechCoder
commented
Jul 6, 2016
Outside of this PR, I would like to either:
(The 2nd one more preferable) |
sethah
commented
Jul 11, 2016
@MechCoder I addressed your comments. I updated the scala doc for |
SparkQA
commented
Jul 11, 2016
Test build #62106 has finished for PR 12374 at commit
|
SparkQA
commented
Jul 20, 2016
Test build #62562 has finished for PR 12374 at commit
|
| val validFeatureSplits = | ||
| Range(0, binAggregates.metadata.numFeaturesPerNode).view.map { featureIndexIdx => | ||
| if (featuresForNode.nonEmpty) { | ||
| (featureIndexIdx, featuresForNode.get.apply(featureIndexIdx)) |
There was a problem hiding this comment.
Is the apply here redundant?
There was a problem hiding this comment.
I don't think so. The alternative is featuresForNode.get(featureIndexIdx) which is misleading even though it does work. It looks like you are calling a function get and passing featureIndexIdx as an argument. Explicit apply seems clearer.
MechCoder
commented
Jul 20, 2016
LGTM |
SparkQA
commented
Jul 25, 2016
Test build #62830 has finished for PR 12374 at commit
|
SparkQA
commented
Aug 25, 2016
Test build #64417 has finished for PR 12374 at commit
|
sethah
commented
Oct 10, 2016
ping @jkbradley or @yanboliang |
SparkQA
commented
Oct 10, 2016
Test build #66676 has finished for PR 12374 at commit
|
jkbradley
commented
Oct 11, 2016
LGTM |
sethah
commented
Oct 11, 2016
Thanks @jkbradley! |
… decision tree training ## What changes were proposed in this pull request? A nonsensical split is produced from method `findSplitsForContinuousFeature` for decision trees. This PR removes the superfluous split and updates unit tests accordingly. Additionally, an assertion to check that the number of found splits is `> 0` is removed, and instead features with zero possible splits are ignored. ## How was this patch tested? A unit test was added to check that finding splits for a constant feature produces an empty array. Author: sethah <seth.hendrickson16@gmail.com> Closesapache#12374 from sethah/SPARK-14610.
What changes were proposed in this pull request?
A nonsensical split is produced from method
findSplitsForContinuousFeaturefor decision trees. This PR removes the superfluous split and updates unit tests accordingly. Additionally, an assertion to check that the number of found splits is> 0is removed, and instead features with zero possible splits are ignored.How was this patch tested?
A unit test was added to check that finding splits for a constant feature produces an empty array.