Uh oh!
There was an error while loading. Please reload this page.
[SPARK-17017][Follow-up][ML] Refactor of ChiSqSelector and add ML Python API. - #15214
[SPARK-17017][Follow-up][ML] Refactor of ChiSqSelector and add ML Python API.#15214yanboliang wants to merge 2 commits into
Conversation
srowen
commented
Sep 23, 2016
Oh I see. I trust your judgment on this, just wish we could have gotten your review on the original PR. @mpjlu what do you think? |
SparkQA
commented
Sep 23, 2016
Test build #65824 has finished for PR 15214 at commit
|
mpjlu
commented
Sep 23, 2016
Hi @srowen and @yanboliang ; Thanks for your following up PR. |
| case ChiSqSelectorType.KBest => | ||
| val selector = new feature.ChiSqSelector() | ||
| $(selectorType) match { | ||
| case OldChiSqSelector.KBest => |
| case OldChiSqSelector.Percentile => | ||
| selector.setPercentile($(percentile)) | ||
| case ChiSqSelectorType.FPR => | ||
| case OldChiSqSelector.FPR => |
| @@ -160,6 +166,12 @@ final class ChiSqSelector @Since("1.6.0") (@Since("1.6.0") override val uid: Str | |||
| @Since("1.6.0") | |||
| override def transformSchema(schema: StructType): StructType = { | |||
| LabeledPoint(1.0, Vectors.dense(Array(4.0))), | ||
| LabeledPoint(2.0, Vectors.dense(Array(9.0)))) | ||
| val model = new ChiSqSelector().setAlpha(0.1).fit(labeledDiscreteData) | ||
| val model = new ChiSqSelector().setSelectorType("fpr").setAlpha(0.1).fit(labeledDiscreteData) |
There was a problem hiding this comment.
you should also do the same thing for https://github.com/apache/spark/blob/master/mllib/src/test/scala/org/apache/spark/ml/feature/ChiSqSelectorSuite.scala
yanboliang
commented
Sep 24, 2016
@mpjlu The most important cause of this change is that the fit/train model should not dependent on the order of users setting params. In other words, users should get the same model whether set A following B or B following A. Thanks! |
SparkQA
commented
Sep 24, 2016
Test build #65864 has finished for PR 15214 at commit
|
mpjlu
commented
Sep 24, 2016
Hi @yanboliang , got it. Thanks. |
srowen
commented
Sep 25, 2016
I'm OK with it. @mpjlu sounds like you approve? |
mpjlu
commented
Sep 25, 2016
hi @srowen . In this PR, setFPR(0.05) is split to two functions: setSelectorType("fpr").setAlpha(0.05). This maybe clear to the user. |
srowen
commented
Sep 25, 2016
OK, I could also support either behavior. After all, for any component, |
@srowen@mpjlu If users are not very familiar with |
yanboliang
commented
Sep 25, 2016
And you can also refer all other Estimator in ML, even you swap the arguments setting order, you still get the same model. Thanks. |
mpjlu
commented
Sep 25, 2016
Thanks, this looks good to me. |
mpjlu
commented
Sep 25, 2016
Hi @srowen , sorry for forgetting update the doc and python/ml/feature.py in last PR. |
srowen
commented
Sep 26, 2016
Merged to master |
What changes were proposed in this pull request?
#14597 modified
ChiSqSelectorto supportfprtype selector, however, it left some issue need to be addressed:numTopFeaturesandpercentile, it will trainkbestorpercentilemodel based on the order of setting (the latter setting one will be trained). This make users confused, and we should allow users to set selector type explicitly. We handle similar issues at other place of ML code base such asGeneralizedLinearRegressionandLogisticRegression.alphacan be set forfprmodel, we can not handle it elegantly in the existing framework. And similar issues forkbestandpercentilemodel. Setting selector type explicitly can solve this issue also.selectorType = percentileandalpha = 0.1, we should notify users the parameteralphawill take no effect. We should handle complex parameter interaction checks attransformSchema. (FYI [SPARK-13761] [ML] Deprecate validateParams #11620)How was this patch tested?
Unit test.