Uh oh!
There was an error while loading. Please reload this page.
[SPARK-10524][ML] Use the soft prediction to order categories' bins - #8734
[SPARK-10524][ML] Use the soft prediction to order categories' bins#8734viirya wants to merge 8 commits into
Conversation
SparkQA
commented
Sep 13, 2015
Test build #42382 has finished for PR 8734 at commit
|
There was a problem hiding this comment.
Can you please update this test to call binsToBestSplit directly? You can change it to be private[tree] so that it's callable from this test suite.
There was a problem hiding this comment.
In order to call binsToBestSplit directly, we need to expose many details of findBestSplits too, e.g., binSeqOp, getNodeToFeatures and partitionAggregates...etc., because binsToBestSplit needs binAggregates and featuresForNode..etc. as parameters. Is it a good idea?
jkbradley
commented
Dec 30, 2015
I'll have bandwidth to get this merged now, so I'll watch for updates. Thanks! |
jkbradley
commented
Jan 14, 2016
Ping! Please let me know if you don't have time to work on this, and I can take it over. Thanks |
viirya
commented
Jan 14, 2016
@jkbradley Sorry for replying late. I will try to finish this soon. Thanks. |
jkbradley
commented
Jan 14, 2016
OK thanks! |
SparkQA
commented
Jan 20, 2016
Test build #49757 has finished for PR 8734 at commit
|
There was a problem hiding this comment.
I don't believe this is correct. Ordering by the probability of the prediction is essentially the same as ordering by impurity. That's because when the impurity is low, the predicted value will have high probability and vice versa.
From Hastie, Tibshirani, and Friedman:
"We order the predictor classes according to the proportion falling in outcome class 1. Then we split this predictor as if it were an ordered predictor."
For binary category I think it should be as @jkbradley suggested categoryStats.stats(1)
There was a problem hiding this comment.
As I saw from the implementation, categoryStats.stats(1) is just the count of class 1, not the proportion falling in outcome class 1. Are we going to order bins by that?
There was a problem hiding this comment.
Finding the proportion falling in outcome class 1 simply requires division of the counts by a constant. Since we're just using that number for an ordering, constant division won't matter. They are the same.
My initial comment has a typo. It should say for a "binary outcome", not "binary category".
There was a problem hiding this comment.
Yeah, I see. I was thinking we are going to order them by soft prediction of each bin. Actually what we want is to order them by soft prediction of certain class.
SparkQA
commented
Jan 21, 2016
Test build #49865 has finished for PR 8734 at commit
|
SparkQA
commented
Jan 21, 2016
Test build #49874 has finished for PR 8734 at commit
|
There was a problem hiding this comment.
I think you meant categoryStats.stats.length == 2. categoryStats.count is the count of data points falling into that particular bin. Since we are trying to determine here whether this is regression or binary classification, I think checking if (binAggregates.metadata.isClassification) is more clear.
Additionally, the code under the if and else statements of centroidForCategories is identical except for a single line. It seems cleaner to restructure to something like:
valcentroidForCategories=Range(0, numCategories).map { case featureValue =>valcategoryStats=
binAggregates.getImpurityCalculator(nodeFeatureOffset, featureValue)
valcentroid=if (categoryStats.count !=0) {
if (binAggregates.metadata.isMulticlass) {
// multiclass classification
categoryStats.calculate()
} elseif (binAggregates.metadata.isClassification) {
// binary classification
categoryStats.stats(1)
} else {
// regression
categoryStats.predict
}
} else {
Double.MaxValue
}
(featureValue, centroid)
}There was a problem hiding this comment.
@sethah Thanks. You are right. I didn't read this part of codes thoroughly.
SparkQA
commented
Jan 23, 2016
Test build #49934 has finished for PR 8734 at commit
|
jkbradley
commented
Feb 9, 2016
sethah
commented
Feb 9, 2016
Yes, LGTM pending the improved test, thanks! |
jkbradley
commented
Feb 9, 2016
Fixed unit test and added one to spark.ml
viirya
commented
Feb 10, 2016
@jkbradley Great thanks. I've merged your PR. |
SparkQA
commented
Feb 10, 2016
Test build #51012 has finished for PR 8734 at commit
|
JIRA: https://issues.apache.org/jira/browse/SPARK-10524
Currently we use the hard prediction (
ImpurityCalculator.predict) to order categories' bins. But we should use the soft prediction.