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

    https://github.com/apache/spark/pull/17715#discussion_r113652694
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala
 ---
    @@ -1149,6 +1300,49 @@ class LogisticRegressionSuite
         assert(model2.interceptVector.toArray.sum ~== 0.0 absTol eps)
       }
     
    +  test("multinomial logistic regression with intercept without 
regularization with bound") {
    +    val lowerBoundOfCoefficients = Matrices.dense(3, 4, 
Array.fill(12)(1.0))
    +    val lowerBoundOfIntercept = Vectors.dense(Array.fill(3)(1.0))
    +
    +    val trainer1 = new LogisticRegression()
    +      .setLowerBoundOfCoefficients(lowerBoundOfCoefficients)
    +      .setLowerBoundOfIntercept(lowerBoundOfIntercept)
    +      .setFitIntercept(true)
    +      .setStandardization(true)
    +      .setWeightCol("weight")
    +    val trainer2 = new LogisticRegression()
    +      .setLowerBoundOfCoefficients(lowerBoundOfCoefficients)
    +      .setLowerBoundOfIntercept(lowerBoundOfIntercept)
    +      .setFitIntercept(true)
    +      .setStandardization(false)
    +      .setWeightCol("weight")
    +
    +    val model1 = trainer1.fit(multinomialDataset)
    +    val model2 = trainer2.fit(multinomialDataset)
    +
    +    // The solution is generated by 
https://github.com/yanboliang/bound-optimization.
    +    val coefficientsExpected = new DenseMatrix(3, 4, Array(
    +      2.52076464, 2.73596057, 1.87984904, 2.73264492,
    +      1.93302281, 3.71363303, 1.50681746, 1.93398782,
    +      2.37839917, 1.93601818, 1.81924758, 2.45191255), isTransposed = true)
    --- End diff --
    
    We can't hit the lower bound condition even I make the lower bounds as 2.0, 
or even 5.0 for this dataset. But I added a test have both lower and upper 
bounds ([1.0, 2.0]), the solution hit both bounds.
    ```val coefficientsExpected3 = new DenseMatrix(3, 4, Array(
          1.61967097, 1.16027835, 1.45131448, 1.97390431,
          1.30529317, 2.0, 1.12985473, 1.26652854,
          1.61647195, 1.0, 1.40642959, 1.72985589), isTransposed = true)
        val interceptsExpected3 = Vectors.dense(1.0, 2.0, 2.0)
    ```


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