spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From holdenk <...@git.apache.org>
Subject [GitHub] spark pull request: [Spark-7780][MLLIB] Intercept in logisticregre...
Date Wed, 03 Jun 2015 00:37:34 GMT
Github user holdenk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6386#discussion_r31585441
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
---
    @@ -363,4 +371,54 @@ 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
    +   * or feature scaling is disabled, 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 && useFeatureScaling) {
    +      def runWithMlLogisitcRegression(elasticNetParam: Double) = {
    +        // Prepare the ml LogisticRegression based on our settings
    +        val lr = new org.apache.spark.ml.classification.LogisticRegression()
    +        lr.setRegParam(optimizer.getRegParam())
    +        lr.setElasticNetParam(elasticNetParam)
    +        val initialWeightsWithIntercept = Vectors.dense(0.0, initialWeights.toArray:_*)
    --- End diff --
    
    Ok. We could avoid adding this if we overrode run w/out weights in `LogisiticRegressionWithlLBFGS`
and added another run which takes if the weights are user supplied or not that the two different
runs will call, I'm not sure its any less ugly (thoughts?)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message