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

    https://github.com/apache/spark/pull/11549#discussion_r56289063
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/r/SparkRWrappers.scala 
---
    @@ -17,15 +17,41 @@
     
     package org.apache.spark.ml.api.r
     
    +import org.apache.spark.SparkException
     import org.apache.spark.ml.{Pipeline, PipelineModel}
     import org.apache.spark.ml.attribute._
     import org.apache.spark.ml.classification.{LogisticRegression, 
LogisticRegressionModel}
     import org.apache.spark.ml.clustering.{KMeans, KMeansModel}
     import org.apache.spark.ml.feature.{RFormula, VectorAssembler}
    -import org.apache.spark.ml.regression.{LinearRegression, 
LinearRegressionModel}
    +import org.apache.spark.ml.regression._
     import org.apache.spark.sql.DataFrame
     
     private[r] object SparkRWrappers {
    +  def fitGLM(
    +      value: String,
    +      df: DataFrame,
    +      family: String,
    +      lambda: Double,
    +      solver: String): PipelineModel = {
    +    if (solver.trim != "irls") throw new SparkException("Currently only 
support irls")
    +
    +    val formula = new RFormula().setFormula(value)
    +    val regex = 
"^\\s*(\\w+)\\s*(\\(\\s*link\\s*=\\s*\"(\\w+)\"\\s*\\))?\\s*$".r
    +    val estimator = family match {
    +      case regex(familyName, group2, linkName) =>
    --- End diff --
    
    +1. The regex is unnecessary at here, ```RFormula``` can parse formula and 
handle illegal formula. 
    You may noticed that I use regex in #11447, that is because we only support 
a subset  of the formula in ```survreg``` currently.


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