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

    https://github.com/apache/spark/pull/17715#discussion_r113071333
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala
 ---
    @@ -650,6 +711,34 @@ class LogisticRegressionSuite
         assert(model2.coefficients ~= coefficientsR relTol 1E-2)
       }
     
    +  test("binary logistic regression without intercept without 
regularization with bound") {
    +    val upperBoundOfCoefficients = Matrices.dense(1, 4, Array(1.0, 0.0, 
1.0, 0.0))
    +
    +    val trainer1 = new LogisticRegression()
    +      .setUpperBoundOfCoefficients(upperBoundOfCoefficients)
    +      .setFitIntercept(false)
    +      .setStandardization(true)
    +      .setWeightCol("weight")
    +    val trainer2 = new LogisticRegression()
    +      .setUpperBoundOfCoefficients(upperBoundOfCoefficients)
    +      .setFitIntercept(false)
    +      .setStandardization(false)
    +      .setWeightCol("weight")
    +
    +    val model1 = trainer1.fit(binaryDataset)
    +    val model2 = trainer2.fit(binaryDataset)
    +
    +    // The solution is generated by 
https://github.com/yanboliang/bound-optimization.
    +    val coefficientsExpected = Vectors.dense(0.20847553, 0.0, -0.24240289, 
-0.55568071)
    +
    +    assert(model1.intercept ~== 0.0 relTol 1E-3)
    +    assert(model1.coefficients ~= coefficientsExpected relTol 1E-3)
    +
    +    // Without regularization, with or without standardization will 
converge to the same solution.
    +    assert(model2.intercept ~== 0.0 relTol 1E-3)
    +    assert(model2.coefficients ~= coefficientsExpected relTol 1E-3)
    +  }
    +
       test("binary logistic regression with intercept with L1 regularization") 
{
    --- End diff --
    
    Can we add a test having lower bounds for non-negativity? 


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