Github user dbtsai commented on a diff in the pull request:
https://github.com/apache/spark/pull/17715#discussion_r113052881
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
---
@@ -434,8 +587,45 @@ class LogisticRegression @Since("1.2.0") (
$(standardization), bcFeaturesStd, regParamL2, multinomial =
isMultinomial,
$(aggregationDepth))
+ val numCoeffs = numFeaturesPlusIntercept * numCoefficientSets
+ val isSetLowerBoundOfCoefficients = isSet(lowerBoundOfCoefficients)
+ val isSetUpperBoundOfCoefficients = isSet(upperBoundOfCoefficients)
+ val isSetLowerBoundOfIntercept = isSet(lowerBoundOfIntercept)
+ val isSetUpperBoundOfIntercept = isSet(upperBoundOfIntercept)
+ var lowerBound: Array[Double] = null
+ var upperBound: Array[Double] = null
+
val optimizer = if ($(elasticNetParam) == 0.0 || $(regParam) ==
0.0) {
- new BreezeLBFGS[BDV[Double]]($(maxIter), 10, $(tol))
+ if (usingBoundConstrainedOptimization) {
+ lowerBound =
Array.fill[Double](numCoeffs)(Double.NegativeInfinity)
+ upperBound =
Array.fill[Double](numCoeffs)(Double.PositiveInfinity)
+ var i = 0
+ while (i < numCoeffs) {
+ val coefficientSetIndex = i % numCoefficientSets
+ val featureIndex = i / numCoefficientSets
+ if (featureIndex < numFeatures) {
+ if (isSetLowerBoundOfCoefficients) {
+ lowerBound(i) = $(lowerBoundOfCoefficients)(
+ coefficientSetIndex, featureIndex) *
featuresStd(featureIndex)
+ }
+ if (isSetUpperBoundOfCoefficients) {
+ upperBound(i) = $(upperBoundOfCoefficients)(
+ coefficientSetIndex, featureIndex) *
featuresStd(featureIndex)
+ }
+ } else {
+ if (isSetLowerBoundOfIntercept) {
+ lowerBound(i) =
$(lowerBoundOfIntercept)(coefficientSetIndex)
+ }
+ if (isSetUpperBoundOfIntercept) {
+ upperBound(i) =
$(upperBoundOfIntercept)(coefficientSetIndex)
+ }
+ }
+ i += 1
+ }
+ new LBFGSB(BDV[Double](lowerBound), BDV[Double](upperBound),
$(maxIter), 10, $(tol))
--- End diff --
`BreezeLBFGSB` for explicitly using Breeze implementation.
---
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]