Github user dbtsai commented on a diff in the pull request:
https://github.com/apache/spark/pull/3833#discussion_r22963566
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
---
@@ -18,30 +18,36 @@
package org.apache.spark.mllib.classification
import org.apache.spark.annotation.Experimental
-import org.apache.spark.mllib.linalg.Vector
+import org.apache.spark.mllib.linalg.BLAS.dot
+import org.apache.spark.mllib.linalg.{DenseVector, Vector}
import org.apache.spark.mllib.optimization._
import org.apache.spark.mllib.regression._
-import org.apache.spark.mllib.util.DataValidators
+import org.apache.spark.mllib.util.{DataValidators, MLUtils}
import org.apache.spark.rdd.RDD
/**
- * Classification model trained using Logistic Regression.
+ * Classification model trained using Multinomial/Binary Logistic
Regression.
*
* @param weights Weights computed for every feature.
- * @param intercept Intercept computed for this model.
+ * @param intercept Intercept computed for this model. (Only used in
Binary Logistic Regression.
+ * In Multinomial Logistic Regression, the intercepts
will not be a single values,
+ * so the intercepts will be part of the weights.)
+ * @param nClasses The number of possible outcomes for Multinomial
Logistic Regression.
+ * The default value is 2 which is Binary Logistic
Regression.
*/
class LogisticRegressionModel (
override val weights: Vector,
- override val intercept: Double)
+ override val intercept: Double,
+ nClasses: Int = 2)
extends GeneralizedLinearModel(weights, intercept) with
ClassificationModel with Serializable {
private var threshold: Option[Double] = Some(0.5)
/**
* :: Experimental ::
- * Sets the threshold that separates positive predictions from negative
predictions. An example
- * with prediction score greater than or equal to this threshold is
identified as an positive,
- * and negative otherwise. The default value is 0.5.
+ * Sets the threshold that separates positive predictions from negative
predictions
+ * in Binary Logistic Regression. An example with prediction score
greater than or equal to
+ * this threshold is identified as an positive, and negative otherwise.
The default value is 0.5.
*/
--- End diff --
I think the model should have api to predict as probability, and we have
another transformer to take threshold so we can reuse the logic for all the
probabilistic model. I will like to remove threshold stuff from LOR entirely.
@mengxr what do u think?
---
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]