Github user dbtsai commented on a diff in the pull request:
https://github.com/apache/spark/pull/6386#discussion_r30955191
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
---
@@ -363,4 +370,36 @@ class LogisticRegressionWithLBFGS
new LogisticRegressionModel(weights, intercept, numFeatures,
numOfLinearPredictor + 1)
}
}
+
+ /**
+ * Run the algorithm with the configured parameters on an input RDD
+ * of LabeledPoint entries starting from the initial weights provided.
+ * If a known updater is used calls the ml implementation, to avoid
+ * applying a regularization penalty to the intercept, otherwise
+ * defaults to the mllib implementation. If more than two classes
+ * always uses mllib implementation.
+ */
+ override def run(input: RDD[LabeledPoint], initialWeights: Vector):
LogisticRegressionModel = {
+ // ml's Logisitic regression only supports binary classifcation
currently.
+ if (numOfLinearPredictor == 1) {
+ def runWithMlLogisitcRegression(elasticNetParam: Double) = {
+ val lr = new
org.apache.spark.ml.classification.LogisticRegression()
+ lr.setRegParam(optimizer.getRegParam())
+ val handlePersistence = input.getStorageLevel == StorageLevel.NONE
+ val instances = input.map {
+ case LabeledPoint(label: Double, features: Vector) => (label,
features)
+ }
+ val mlLogisticRegresionModel = lr.trainOnInstances(instances,
handlePersistence,
+ Some(initialWeights))
--- End diff --
Yes
---
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]