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

    https://github.com/apache/spark/pull/8884#discussion_r41808787
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala ---
    @@ -130,9 +131,54 @@ class LinearRegression(override val uid: String)
       def setWeightCol(value: String): this.type = set(weightCol, value)
       setDefault(weightCol -> "")
     
    +  /**
    +   * Set the solver algorithm used for optimization.
    +   * In case of linear regression, this can be "l-bfgs", "normal" and 
"auto".
    +   * The default value is "auto" which means that the solver algorithm is
    +   * selected automatically.
    +   * @group setParam
    +   */
    +  def setSolver(value: String): this.type = set(solver, value)
    +  setDefault(solver -> "auto")
    +
       override protected def train(dataset: DataFrame): LinearRegressionModel 
= {
    +    // Extract the number of features before deciding optimization solver.
    +    val numFeatures = dataset.select(col($(featuresCol))).limit(1).map {
    +      case Row(features: Vector) =>
    +        features.size
    +    }.toArray()(0)
         // Extract columns from data.  If dataset is persisted, do not persist 
instances.
         val w = if ($(weightCol).isEmpty) lit(1.0) else col($(weightCol))
    +
    +    if ($(solver) == "normal" || ($(solver) == "auto"
    +      && $(elasticNetParam) == 0.0 && numFeatures <= 4096)) {
    --- End diff --
    
    For readability, 
    
    ```scala
    if (($(solver) == "auto" && $(elasticNetParam) == 0.0 && numFeatures <= 
4096) || 
        $(solver) == "normal") {
    ```



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