Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1862#discussion_r16023088
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala
 ---
    @@ -188,3 +188,54 @@ object LogisticRegressionWithSGD {
         train(input, numIterations, 1.0, 1.0)
       }
     }
    +
    +/**
    + * Train a classification model for Logistic Regression using 
Limited-memory BFGS.
    + * NOTE: Labels used in Logistic Regression should be {0, 1}
    + */
    +class LogisticRegressionWithLBFGS private (
    +    private var convergenceTol: Double,
    +    private var maxNumIterations: Int,
    +    private var regParam: Double)
    +  extends GeneralizedLinearAlgorithm[LogisticRegressionModel] with 
Serializable {
    +
    +  private val gradient = new LogisticGradient()
    +  private val updater = new SimpleUpdater()
    +  // Have to be lazy since users can change the parameters after the class 
is created.
    +  // PS, after the first train, the optimizer variable will be computed, 
so the parameters
    +  // can not be changed anymore.
    +  override lazy val optimizer = new LBFGS(gradient, updater)
    +    .setNumCorrections(10)
    +    .setConvergenceTol(convergenceTol)
    +    .setMaxNumIterations(maxNumIterations)
    +    .setRegParam(regParam)
    +
    +  override protected val validators = 
List(DataValidators.binaryLabelValidator)
    +
    +  /**
    +   * Construct a LogisticRegression object with default parameters
    +   */
    +  def this() = this(1E-4, 100, 0.0)
    +
    +  /**
    +   * Set the convergence tolerance of iterations for L-BFGS. Default 1E-4.
    +   * Smaller value will lead to higher accuracy with the cost of more 
iterations.
    +   */
    +  def setConvergenceTol(tolerance: Double): this.type = {
    +    this.convergenceTol = tolerance
    +    this
    +  }
    +
    +  /**
    +   * Set the maximal number of iterations for L-BFGS. Default 100.
    +   */
    +  def setMaxNumIterations(iters: Int): this.type = {
    --- End diff --
    
    which one?


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

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

Reply via email to