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

    https://github.com/apache/spark/pull/10940#discussion_r51051112
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
 ---
    @@ -341,11 +341,11 @@ class LogisticRegression @Since("1.2.0") (
                     regParamL1
                   } else {
                     // If `standardization` is false, we still standardize the 
data
    -                // to improve the rate of convergence; as a result, we 
have to
    -                // perform this reverse standardization by penalizing each 
component
    -                // differently to get effectively the same objective 
function when
    +                // to improve the rate of convergence unless the standard 
deviation is zero;
    +                // as a result, we have to perform this reverse 
standardization by penalizing
    +                // each component differently to get effectively the same 
objective function when
                     // the training dataset is not standardized.
    -                if (featuresStd(index) != 0.0) regParamL1 / 
featuresStd(index) else 0.0
    +                if (featuresStd(index) != 0.0) regParamL1 / 
featuresStd(index) else regParamL1
    --- End diff --
    
    The constant `value` can be really large or very small negatively. The 
optimizer may not be able to converge well in this case. I don't prove or try 
it yet, but mathematically, with the following changes, this should be solving 
identical problem.
    
    ```scala
    // the training dataset is not standardized.
    if (featuresStd(index) != 0.0) regParamL1 / featuresStd(index) else 
regParamL1 / featuresMean(index)
    ```


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