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

    https://github.com/apache/spark/pull/14597#discussion_r74404348
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/feature/ChiSqSelector.scala ---
    @@ -197,3 +197,28 @@ class ChiSqSelector @Since("1.3.0") (
         new ChiSqSelectorModel(indices)
       }
     }
    +
    +/**
    + * Creates a ChiSquared feature selector by False Positive Rate (FPR) test.
    + * @param alpha the highest p-value for features to be kept
    + */
    +@Since("2.1.0")
    +class ChiSqSelectorByFpr @Since("2.1.0") (
    +  @Since("2.1.0") val alpha: Double) extends Serializable {
    +
    +  /**
    +   * Returns a ChiSquared feature selector by FPR.
    +   *
    +   * @param data an `RDD[LabeledPoint]` containing the labeled dataset 
with categorical features.
    +   *             Real-valued features will be treated as categorical for 
each distinct value.
    +   *             Apply feature discretizer before using this function.
    +   */
    +  @Since("2.1.0")
    +  def fit(data: RDD[LabeledPoint]): ChiSqSelectorModel = {
    +    val indices = Statistics.chiSqTest(data)
    +      .zipWithIndex.filter { case (res, _) => res.pValue < alpha }
    --- End diff --
    
    The only problem here is how to the reuse the result of  
"Statistics.chiSqTest(data)", so why not add a var to save the result.  we 
don't need to change the model related code.  Just need to add two lines of 
code to check which selection method is used. No API needs to change.  We need 
to add API to set parameters about other selection methods, like select by FPR. 
How do you think about it. @srowen  


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to