Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/17715#discussion_r114031122
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
---
@@ -178,11 +178,86 @@ private[classification] trait
LogisticRegressionParams extends ProbabilisticClas
}
}
+ /**
+ * The lower bounds on coefficients if fitting under bound constrained
optimization.
+ * The bound matrix must be compatible with the shape (1, number of
features) for binomial
+ * regression, or (number of classes, number of features) for
multinomial regression.
+ * Otherwise, it throws exception.
+ *
+ * @group param
+ */
+ @Since("2.2.0")
+ val lowerBoundsOnCoefficients: Param[Matrix] = new Param(this,
"lowerBoundsOnCoefficients",
+ "The lower bounds on coefficients if fitting under bound constrained
optimization.")
+
+ /** @group getParam */
+ @Since("2.2.0")
+ def getLowerBoundsOnCoefficients: Matrix = $(lowerBoundsOnCoefficients)
+
+ /**
+ * The upper bounds on coefficients if fitting under bound constrained
optimization.
+ * The bound matrix must be compatible with the shape (1, number of
features) for binomial
+ * regression, or (number of classes, number of features) for
multinomial regression.
+ * Otherwise, it throws exception.
+ *
+ * @group param
+ */
+ @Since("2.2.0")
+ val upperBoundsOnCoefficients: Param[Matrix] = new Param(this,
"upperBoundsOnCoefficients",
+ "The upper bounds on coefficients if fitting under bound constrained
optimization.")
+
+ /** @group getParam */
+ @Since("2.2.0")
+ def getUpperBoundsOnCoefficients: Matrix = $(upperBoundsOnCoefficients)
+
+ /**
+ * The lower bounds on intercepts if fitting under bound constrained
optimization.
+ * The bounds vector size must be equal with 1 for binomial regression,
or the number
+ * of classes for multinomial regression. Otherwise, it throws exception.
+ *
+ * @group param
+ */
+ @Since("2.2.0")
+ val lowerBoundsOnIntercepts: Param[Vector] = new Param(this,
"lowerBoundsOnIntercepts",
+ "The lower bounds on intercepts if fitting under bound constrained
optimization.")
+
+ /** @group getParam */
+ @Since("2.2.0")
+ def getLowerBoundsOnIntercepts: Vector = $(lowerBoundsOnIntercepts)
+
+ /**
+ * The upper bounds on intercepts if fitting under bound constrained
optimization.
+ * The bound vector size must be equal with 1 for binomial regression,
or the number
+ * of classes for multinomial regression. Otherwise, it throws exception.
+ *
+ * @group param
+ */
+ @Since("2.2.0")
+ val upperBoundsOnIntercepts: Param[Vector] = new Param(this,
"upperBoundsOnIntercepts",
+ "The upper bounds on intercepts if fitting under bound constrained
optimization.")
+
+ /** @group getParam */
+ @Since("2.2.0")
+ def getUpperBoundsOnIntercepts: Vector = $(upperBoundsOnIntercepts)
+
+ protected def usingBoundConstrainedOptimization: Boolean = {
+ isSet(lowerBoundsOnCoefficients) || isSet(upperBoundsOnCoefficients) ||
+ isSet(lowerBoundsOnIntercepts) || isSet(upperBoundsOnIntercepts)
+ }
+
override protected def validateAndTransformSchema(
schema: StructType,
fitting: Boolean,
featuresDataType: DataType): StructType = {
checkThresholdConsistency()
+ if (usingBoundConstrainedOptimization) {
+ require($(elasticNetParam) == 0.0, "Fitting under bound constrained
optimization only " +
+ s"supports L2 regularization, but got elasticNetParam =
$getElasticNetParam.")
+ }
+ if (!$(fitIntercept)) {
+ require(!isSet(lowerBoundsOnIntercepts) &&
!isSet(upperBoundsOnIntercepts),
+ "Pls don't set bounds on intercepts if fitting without intercept.")
--- End diff --
"Pls don't" --> "Please do not"
---
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]