Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15277#discussion_r81102445
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/feature/ChiSqSelector.scala ---
    @@ -220,18 +231,22 @@ class ChiSqSelector @Since("2.1.0") () extends 
Serializable {
       @Since("1.3.0")
       def fit(data: RDD[LabeledPoint]): ChiSqSelectorModel = {
         val chiSqTestResult = Statistics.chiSqTest(data)
    -      .zipWithIndex.sortBy { case (res, _) => -res.statistic }
         val features = selectorType match {
    -      case ChiSqSelector.KBest => chiSqTestResult
    -        .take(numTopFeatures)
    -      case ChiSqSelector.Percentile => chiSqTestResult
    -        .take((chiSqTestResult.length * percentile).toInt)
    -      case ChiSqSelector.FPR => chiSqTestResult
    -        .filter{ case (res, _) => res.pValue < alpha }
    +      case ChiSqSelector.KBest =>
    +        chiSqTestResult.zipWithIndex
    +          .sortBy { case (res, _) => -res.statistic }
    +          .take(numTopFeatures)
    +      case ChiSqSelector.Percentile =>
    +        chiSqTestResult.zipWithIndex
    +          .sortBy { case (res, _) => -res.statistic }
    +          .take((chiSqTestResult.length * percentile).toInt)
    +      case ChiSqSelector.FPR =>
    +        chiSqTestResult.zipWithIndex
    +          .filter{ case (res, _) => res.pValue < alpha }
    --- End diff --
    
    It's true. Originally I though it would make sense to present the statistic 
to the model because it has no way to recover it, and further made sense to 
rank by the statistic anyway, but subsequent changes make that irrelevant.


---
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]

Reply via email to