You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by dbtsai <gi...@git.apache.org> on 2014/05/09 01:41:49 UTC

[GitHub] spark pull request: L-BFGS Documentation

GitHub user dbtsai opened a pull request:

    https://github.com/apache/spark/pull/702

    L-BFGS Documentation

    Documentation for L-BFGS, and an example of training binary L2 logistic regression using L-BFGS.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dbtsai/spark dbtsai-lbfgs-doc

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/702.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #702
    
----
commit bbd9db595aa845ea82f79a0b888e7479f5b4b0af
Author: DB Tsai <db...@alpinenow.com>
Date:   2014-05-08T01:42:18Z

    L-BFGS Documentation

----


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42735249
  
    Merged build started. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42624702
  
    Merged build finished. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460451
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +177,100 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegression).
    +See the example below. It will be addressed in the next release. 
    +
    +The L1 regularization by using 
    +[Updater.L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.Updater) will not work since the 
    +soft-thresholding logic in L1Updater is designed for gradient descent.
    +
    +The L-BFGS method
    +[LBFGS.runLBFGS](api/scala/index.html#org.apache.spark.mllib.optimization.LBFGS)
    +has the following parameters:
    +
    +* `gradient` is a class that computes the gradient of the objective function
    +being optimized, i.e., with respect to a single training example, at the
    +current parameter value. MLlib includes gradient classes for common loss
    +functions, e.g., hinge, logistic, least-squares.  The gradient class takes as
    +input a training example, its label, and the current parameter value. 
    +* `updater` is a class originally designed for gradient decent which computes 
    --- End diff --
    
    Let's remove this paragraph or move it to a separate `Developer` section. For the guide, we better separate user-facing content from developer-facing content.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460330
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -128,10 +128,24 @@ is sampled, i.e. `$|S|=$ miniBatchFraction $\cdot n = 1$`, then the algorithm is
     standard SGD. In that case, the step direction depends from the uniformly random sampling of the
     point.
     
    +### Limited-memory BFGS
    +[Limited-memory BFGS (L-BFGS)](http://en.wikipedia.org/wiki/Limited-memory_BFGS) is an optimization 
    +algorithm in the family of quasi-Newton methods to solve the optimization problems of the form 
    +`$\min_{\wv \in\R^d} \; f(\wv)$`. The L-BFGS approximates the objective function locally as a quadratic
    +without evaluating the second partial derivatives of the objective function to construct the 
    +Hessian matrix. The Hessian matrix is approximated by previous gradient evaluations, so there is no 
    +vertical scalability issue (the number of training features) when computing the Hessian matrix 
    +explicitly in Newton method. As a result, L-BFGS often achieves rapider convergence compared with 
    --- End diff --
    
    `Newton's method`


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42910647
  
    I've merged this. Thanks.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42724024
  
    Merged build started. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460376
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +177,100 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegression).
    --- End diff --
    
    last `LogisticRegression` -> `LogisticRegressionWithSGD`


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by dbtsai <gi...@git.apache.org>.
Github user dbtsai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12499183
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -128,10 +128,24 @@ is sampled, i.e. `$|S|=$ miniBatchFraction $\cdot n = 1$`, then the algorithm is
     standard SGD. In that case, the step direction depends from the uniformly random sampling of the
     point.
     
    +### Limited-memory BFGS
    +[Limited-memory BFGS (L-BFGS)](http://en.wikipedia.org/wiki/Limited-memory_BFGS) is an optimization 
    +algorithm in the family of quasi-Newton methods to solve the optimization problems of the form 
    +`$\min_{\wv \in\R^d} \; f(\wv)$`. The L-BFGS approximates the objective function locally as a quadratic
    +without evaluating the second partial derivatives of the objective function to construct the 
    +Hessian matrix. The Hessian matrix is approximated by previous gradient evaluations, so there is no 
    +vertical scalability issue (the number of training features) when computing the Hessian matrix 
    +explicitly in Newton method. As a result, L-BFGS often achieves rapider convergence compared with 
    +other first-order optimization. 
     
    +Since the Hessian is constructed approximately from previous gradient evaluations, the objective 
    +function can not be changed during the optimization process. As a result, Stochastic L-BFGS will 
    +not work naively by just using miniBatch; therefore, we don't provide this until we have better 
    +understanding.  
    --- End diff --
    
    Do we have `Developer` section for this type of stuff?


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42735956
  
    All automated tests passed.
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14867/


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42735245
  
     Merged build triggered. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42727302
  
    Merged build finished. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/702


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42724244
  
     Merged build triggered. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460316
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -128,10 +128,24 @@ is sampled, i.e. `$|S|=$ miniBatchFraction $\cdot n = 1$`, then the algorithm is
     standard SGD. In that case, the step direction depends from the uniformly random sampling of the
     point.
     
    +### Limited-memory BFGS
    +[Limited-memory BFGS (L-BFGS)](http://en.wikipedia.org/wiki/Limited-memory_BFGS) is an optimization 
    +algorithm in the family of quasi-Newton methods to solve the optimization problems of the form 
    +`$\min_{\wv \in\R^d} \; f(\wv)$`. The L-BFGS approximates the objective function locally as a quadratic
    --- End diff --
    
    Either `L-BFGS` or `The L-BFGS method`.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460419
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +177,100 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegression).
    +See the example below. It will be addressed in the next release. 
    +
    +The L1 regularization by using 
    +[Updater.L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.Updater) will not work since the 
    --- End diff --
    
    `L1Updater` is not under `Updater`. Should change to
    
    ~~~
    [L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.L1Updater)
    ~~~


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by dbtsai <gi...@git.apache.org>.
Github user dbtsai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12499273
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -128,10 +128,24 @@ is sampled, i.e. `$|S|=$ miniBatchFraction $\cdot n = 1$`, then the algorithm is
     standard SGD. In that case, the step direction depends from the uniformly random sampling of the
     point.
     
    +### Limited-memory BFGS
    +[Limited-memory BFGS (L-BFGS)](http://en.wikipedia.org/wiki/Limited-memory_BFGS) is an optimization 
    +algorithm in the family of quasi-Newton methods to solve the optimization problems of the form 
    +`$\min_{\wv \in\R^d} \; f(\wv)$`. The L-BFGS approximates the objective function locally as a quadratic
    +without evaluating the second partial derivatives of the objective function to construct the 
    +Hessian matrix. The Hessian matrix is approximated by previous gradient evaluations, so there is no 
    +vertical scalability issue (the number of training features) when computing the Hessian matrix 
    +explicitly in Newton method. As a result, L-BFGS often achieves rapider convergence compared with 
    +other first-order optimization. 
     
    +Since the Hessian is constructed approximately from previous gradient evaluations, the objective 
    +function can not be changed during the optimization process. As a result, Stochastic L-BFGS will 
    +not work naively by just using miniBatch; therefore, we don't provide this until we have better 
    +understanding.  
    --- End diff --
    
    I decided to move those message to the code. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460396
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -128,10 +128,24 @@ is sampled, i.e. `$|S|=$ miniBatchFraction $\cdot n = 1$`, then the algorithm is
     standard SGD. In that case, the step direction depends from the uniformly random sampling of the
     point.
     
    +### Limited-memory BFGS
    +[Limited-memory BFGS (L-BFGS)](http://en.wikipedia.org/wiki/Limited-memory_BFGS) is an optimization 
    +algorithm in the family of quasi-Newton methods to solve the optimization problems of the form 
    +`$\min_{\wv \in\R^d} \; f(\wv)$`. The L-BFGS approximates the objective function locally as a quadratic
    +without evaluating the second partial derivatives of the objective function to construct the 
    +Hessian matrix. The Hessian matrix is approximated by previous gradient evaluations, so there is no 
    +vertical scalability issue (the number of training features) when computing the Hessian matrix 
    +explicitly in Newton method. As a result, L-BFGS often achieves rapider convergence compared with 
    +other first-order optimization. 
     
    +Since the Hessian is constructed approximately from previous gradient evaluations, the objective 
    +function can not be changed during the optimization process. As a result, Stochastic L-BFGS will 
    +not work naively by just using miniBatch; therefore, we don't provide this until we have better 
    +understanding.  
     
     ## Implementation in MLlib
     
    +### Gradient descent and Stochastic gradient descent
    --- End diff --
    
    `Stochastic` -> `stochastic`.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460354
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -128,10 +128,24 @@ is sampled, i.e. `$|S|=$ miniBatchFraction $\cdot n = 1$`, then the algorithm is
     standard SGD. In that case, the step direction depends from the uniformly random sampling of the
     point.
     
    +### Limited-memory BFGS
    +[Limited-memory BFGS (L-BFGS)](http://en.wikipedia.org/wiki/Limited-memory_BFGS) is an optimization 
    +algorithm in the family of quasi-Newton methods to solve the optimization problems of the form 
    +`$\min_{\wv \in\R^d} \; f(\wv)$`. The L-BFGS approximates the objective function locally as a quadratic
    +without evaluating the second partial derivatives of the objective function to construct the 
    +Hessian matrix. The Hessian matrix is approximated by previous gradient evaluations, so there is no 
    +vertical scalability issue (the number of training features) when computing the Hessian matrix 
    +explicitly in Newton method. As a result, L-BFGS often achieves rapider convergence compared with 
    +other first-order optimization. 
     
    +Since the Hessian is constructed approximately from previous gradient evaluations, the objective 
    +function can not be changed during the optimization process. As a result, Stochastic L-BFGS will 
    +not work naively by just using miniBatch; therefore, we don't provide this until we have better 
    +understanding.  
    --- End diff --
    
    I think it is safe to remove this paragraph or put it in a separate `Developer` section.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42727301
  
    Merged build finished. All automated tests passed.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by dbtsai <gi...@git.apache.org>.
Github user dbtsai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12502968
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +171,108 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegressionWithSGD).
    +See the example below. It will be addressed in the next release. 
    +
    +The L1 regularization by using 
    +[L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.L1Updater) will not work since the 
    +soft-thresholding logic in L1Updater is designed for gradient descent. See the developer's note.
    +
    +The L-BFGS method
    +[LBFGS.runLBFGS](api/scala/index.html#org.apache.spark.mllib.optimization.LBFGS)
    +has the following parameters:
    +
    +* `gradient` is a class that computes the gradient of the objective function
    +being optimized, i.e., with respect to a single training example, at the
    +current parameter value. MLlib includes gradient classes for common loss
    +functions, e.g., hinge, logistic, least-squares.  The gradient class takes as
    +input a training example, its label, and the current parameter value. 
    +* `updater` is a class that computes the gradient and loss of objective function 
    +of the regularization part for L-BFGS. MLlib includes updaters for cases without 
    +regularization, as well as L2 regularizer. 
    +* `numCorrections` is the number of corrections used in the L-BFGS update. 10 is 
    +recommended.
    +* `maxNumIterations` is the maximal number of iterations that L-BFGS can be run.
    +* `regParam` is the regularization parameter when using regularization.
    +
    +
    +The `return` is a tuple containing two elements. The first element is a column matrix
    +containing weights for every feature, and the second element is an array containing 
    +the loss computed for every iteration.
    +
    +Here is an example to train binary logistic regression with L2 regularization using
    +L-BFGS optimizer. 
    +{% highlight scala %}
    +import org.apache.spark.SparkContext
    +import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics
    +import org.apache.spark.mllib.linalg.Vectors
    +import org.apache.spark.mllib.util.MLUtils
    +import org.apache.spark.mllib.classification.LogisticRegressionModel
    +
    +val data = MLUtils.loadLibSVMFile(sc, "mllib/data/sample_libsvm_data.txt")
    +val numFeatures = data.take(1)(0).features.size
    +
    +// Split data into training (60%) and test (40%).
    +val splits = data.randomSplit(Array(0.6, 0.4), seed = 11L)
    +
    +// Prepend 1 into the training data as intercept.
    +val training = splits(0).map(x => (x.label, MLUtils.appendBias(x.features))).cache()
    +
    +val test = splits(1)
    +
    +// Run training algorithm to build the model
    +val numCorrections = 10
    +val convergenceTol = 1e-4
    +val maxNumIterations = 20
    +val regParam = 0.1
    +val initialWeightsWithIntercept = Vectors.dense(new Array[Double](numFeatures + 1))
    +
    +val (weightsWithIntercept, loss) = LBFGS.runLBFGS(
    +  training,
    +  new LogisticGradient(),
    +  new SquaredL2Updater(),
    +  numCorrections,
    +  convergenceTol,
    +  maxNumIterations,
    +  regParam,
    +  initialWeightsWithIntercept)
    +
    +val model = new LogisticRegressionModel(
    +  Vectors.dense(weightsWithIntercept.toArray.slice(1, weightsWithIntercept.size)),
    --- End diff --
    
    Why don't we have prependOne in the MLUtils as well? Due to the scope, users can not use prependOne. It's more intuitive to have intercept as first element. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12501541
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -128,10 +127,19 @@ is sampled, i.e. `$|S|=$ miniBatchFraction $\cdot n = 1$`, then the algorithm is
     standard SGD. In that case, the step direction depends from the uniformly random sampling of the
     point.
     
    -
    +### L-BFGS
    --- End diff --
    
    This is the first time `L-BFGS` appears in the guide. So let us use `Limited-memory BFGS (L-BFGS)`. Well, it is not necessary to explain `BFGS` .. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by dbtsai <gi...@git.apache.org>.
Github user dbtsai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12499609
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +177,100 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegression).
    +See the example below. It will be addressed in the next release. 
    +
    +The L1 regularization by using 
    +[Updater.L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.Updater) will not work since the 
    +soft-thresholding logic in L1Updater is designed for gradient descent.
    +
    +The L-BFGS method
    +[LBFGS.runLBFGS](api/scala/index.html#org.apache.spark.mllib.optimization.LBFGS)
    +has the following parameters:
    +
    +* `gradient` is a class that computes the gradient of the objective function
    +being optimized, i.e., with respect to a single training example, at the
    +current parameter value. MLlib includes gradient classes for common loss
    +functions, e.g., hinge, logistic, least-squares.  The gradient class takes as
    +input a training example, its label, and the current parameter value. 
    +* `updater` is a class originally designed for gradient decent which computes 
    --- End diff --
    
    Agree. I will move it into the comment in the code.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460502
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +177,100 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegression).
    +See the example below. It will be addressed in the next release. 
    +
    +The L1 regularization by using 
    +[Updater.L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.Updater) will not work since the 
    +soft-thresholding logic in L1Updater is designed for gradient descent.
    +
    +The L-BFGS method
    +[LBFGS.runLBFGS](api/scala/index.html#org.apache.spark.mllib.optimization.LBFGS)
    +has the following parameters:
    +
    +* `gradient` is a class that computes the gradient of the objective function
    +being optimized, i.e., with respect to a single training example, at the
    +current parameter value. MLlib includes gradient classes for common loss
    +functions, e.g., hinge, logistic, least-squares.  The gradient class takes as
    +input a training example, its label, and the current parameter value. 
    +* `updater` is a class originally designed for gradient decent which computes 
    +the actual gradient descent step. However, we're able to take the gradient and 
    +loss of objective function of regularization for L-BFGS by ignoring the part of logic
    +only for gradient decent such as adaptive step size stuff. We will refactorize
    +this into regularizer to replace updater to separate the logic between 
    +regularization and step update later. 
    +* `numCorrections` is the number of corrections used in the L-BFGS update. 10 is 
    +recommended.
    +* `maxNumIterations` is the maximal number of iterations that L-BFGS can be run.
    +* `regParam` is the regularization parameter when using regularization.
    +* `return` A tuple containing two elements. The first element is a column matrix
    +containing weights for every feature, and the second element is an array containing 
    +the loss computed for every iteration.
    +
    +Here is an example to train binary logistic regression with L2 regularization using
    +L-BFGS optimizer. 
    +{% highlight scala %}
    +import org.apache.spark.SparkContext
    +import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics
    +import org.apache.spark.mllib.linalg.Vectors
    +import org.apache.spark.mllib.util.MLUtils
    +import org.apache.spark.mllib.classification.LogisticRegressionModel
    +import breeze.linalg.{DenseVector => BDV}
    +
    +val data = MLUtils.loadLibSVMFile(sc, "mllib/data/sample_libsvm_data.txt")
    +val numFeatures = data.take(1)(0).features.size
    +
    +// Split data into training (60%) and test (40%).
    +val splits = data.randomSplit(Array(0.6, 0.4), seed = 11L)
    +
    +// Prepend 1 into the training data as intercept.
    +val training = splits(0).map(x =>
    +  (x.label, Vectors.fromBreeze(
    +    BDV.vertcat(BDV.ones[Double](1), x.features.toBreeze.toDenseVector)))
    --- End diff --
    
    I added `MLUtils.appendBias` recently. Could you switch to it?


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42727304
  
    
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14860/


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42724251
  
    Merged build started. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42735955
  
    Merged build finished. All automated tests passed.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460483
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +177,100 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegression).
    +See the example below. It will be addressed in the next release. 
    +
    +The L1 regularization by using 
    +[Updater.L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.Updater) will not work since the 
    +soft-thresholding logic in L1Updater is designed for gradient descent.
    +
    +The L-BFGS method
    +[LBFGS.runLBFGS](api/scala/index.html#org.apache.spark.mllib.optimization.LBFGS)
    +has the following parameters:
    +
    +* `gradient` is a class that computes the gradient of the objective function
    +being optimized, i.e., with respect to a single training example, at the
    +current parameter value. MLlib includes gradient classes for common loss
    +functions, e.g., hinge, logistic, least-squares.  The gradient class takes as
    +input a training example, its label, and the current parameter value. 
    +* `updater` is a class originally designed for gradient decent which computes 
    +the actual gradient descent step. However, we're able to take the gradient and 
    +loss of objective function of regularization for L-BFGS by ignoring the part of logic
    +only for gradient decent such as adaptive step size stuff. We will refactorize
    +this into regularizer to replace updater to separate the logic between 
    +regularization and step update later. 
    +* `numCorrections` is the number of corrections used in the L-BFGS update. 10 is 
    +recommended.
    +* `maxNumIterations` is the maximal number of iterations that L-BFGS can be run.
    +* `regParam` is the regularization parameter when using regularization.
    +* `return` A tuple containing two elements. The first element is a column matrix
    --- End diff --
    
    Move `return` out of the list. It may look like a parameter if we put them together.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12460491
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +177,100 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegression).
    +See the example below. It will be addressed in the next release. 
    +
    +The L1 regularization by using 
    +[Updater.L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.Updater) will not work since the 
    +soft-thresholding logic in L1Updater is designed for gradient descent.
    +
    +The L-BFGS method
    +[LBFGS.runLBFGS](api/scala/index.html#org.apache.spark.mllib.optimization.LBFGS)
    +has the following parameters:
    +
    +* `gradient` is a class that computes the gradient of the objective function
    +being optimized, i.e., with respect to a single training example, at the
    +current parameter value. MLlib includes gradient classes for common loss
    +functions, e.g., hinge, logistic, least-squares.  The gradient class takes as
    +input a training example, its label, and the current parameter value. 
    +* `updater` is a class originally designed for gradient decent which computes 
    +the actual gradient descent step. However, we're able to take the gradient and 
    +loss of objective function of regularization for L-BFGS by ignoring the part of logic
    +only for gradient decent such as adaptive step size stuff. We will refactorize
    +this into regularizer to replace updater to separate the logic between 
    +regularization and step update later. 
    +* `numCorrections` is the number of corrections used in the L-BFGS update. 10 is 
    +recommended.
    +* `maxNumIterations` is the maximal number of iterations that L-BFGS can be run.
    +* `regParam` is the regularization parameter when using regularization.
    +* `return` A tuple containing two elements. The first element is a column matrix
    +containing weights for every feature, and the second element is an array containing 
    +the loss computed for every iteration.
    +
    +Here is an example to train binary logistic regression with L2 regularization using
    +L-BFGS optimizer. 
    +{% highlight scala %}
    +import org.apache.spark.SparkContext
    +import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics
    +import org.apache.spark.mllib.linalg.Vectors
    +import org.apache.spark.mllib.util.MLUtils
    +import org.apache.spark.mllib.classification.LogisticRegressionModel
    +import breeze.linalg.{DenseVector => BDV}
    --- End diff --
    
    We don't need `breeze` for the example. See my next comment.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42844008
  
    LGTM. Thanks!


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42624704
  
    
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14829/


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42619666
  
     Merged build triggered. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42727303
  
    All automated tests passed.
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14862/


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12501401
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +171,108 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegressionWithSGD).
    +See the example below. It will be addressed in the next release. 
    +
    +The L1 regularization by using 
    +[L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.L1Updater) will not work since the 
    +soft-thresholding logic in L1Updater is designed for gradient descent. See the developer's note.
    +
    +The L-BFGS method
    +[LBFGS.runLBFGS](api/scala/index.html#org.apache.spark.mllib.optimization.LBFGS)
    +has the following parameters:
    +
    +* `gradient` is a class that computes the gradient of the objective function
    +being optimized, i.e., with respect to a single training example, at the
    +current parameter value. MLlib includes gradient classes for common loss
    +functions, e.g., hinge, logistic, least-squares.  The gradient class takes as
    +input a training example, its label, and the current parameter value. 
    +* `updater` is a class that computes the gradient and loss of objective function 
    +of the regularization part for L-BFGS. MLlib includes updaters for cases without 
    +regularization, as well as L2 regularizer. 
    +* `numCorrections` is the number of corrections used in the L-BFGS update. 10 is 
    +recommended.
    +* `maxNumIterations` is the maximal number of iterations that L-BFGS can be run.
    +* `regParam` is the regularization parameter when using regularization.
    +
    +
    +The `return` is a tuple containing two elements. The first element is a column matrix
    +containing weights for every feature, and the second element is an array containing 
    +the loss computed for every iteration.
    +
    +Here is an example to train binary logistic regression with L2 regularization using
    +L-BFGS optimizer. 
    +{% highlight scala %}
    +import org.apache.spark.SparkContext
    +import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics
    +import org.apache.spark.mllib.linalg.Vectors
    +import org.apache.spark.mllib.util.MLUtils
    +import org.apache.spark.mllib.classification.LogisticRegressionModel
    +
    +val data = MLUtils.loadLibSVMFile(sc, "mllib/data/sample_libsvm_data.txt")
    +val numFeatures = data.take(1)(0).features.size
    +
    +// Split data into training (60%) and test (40%).
    +val splits = data.randomSplit(Array(0.6, 0.4), seed = 11L)
    +
    +// Prepend 1 into the training data as intercept.
    +val training = splits(0).map(x => (x.label, MLUtils.appendBias(x.features))).cache()
    +
    +val test = splits(1)
    +
    +// Run training algorithm to build the model
    +val numCorrections = 10
    +val convergenceTol = 1e-4
    +val maxNumIterations = 20
    +val regParam = 0.1
    +val initialWeightsWithIntercept = Vectors.dense(new Array[Double](numFeatures + 1))
    +
    +val (weightsWithIntercept, loss) = LBFGS.runLBFGS(
    +  training,
    +  new LogisticGradient(),
    +  new SquaredL2Updater(),
    +  numCorrections,
    +  convergenceTol,
    +  maxNumIterations,
    +  regParam,
    +  initialWeightsWithIntercept)
    +
    +val model = new LogisticRegressionModel(
    +  Vectors.dense(weightsWithIntercept.toArray.slice(1, weightsWithIntercept.size)),
    --- End diff --
    
    `appendBias` puts `1.0` at the end of the vector. So the slicing here needs update.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42724013
  
     Merged build triggered. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12501461
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +171,108 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegressionWithSGD).
    +See the example below. It will be addressed in the next release. 
    +
    +The L1 regularization by using 
    +[L1Updater](api/mllib/index.html#org.apache.spark.mllib.optimization.L1Updater) will not work since the 
    +soft-thresholding logic in L1Updater is designed for gradient descent. See the developer's note.
    +
    +The L-BFGS method
    +[LBFGS.runLBFGS](api/scala/index.html#org.apache.spark.mllib.optimization.LBFGS)
    +has the following parameters:
    +
    +* `gradient` is a class that computes the gradient of the objective function
    +being optimized, i.e., with respect to a single training example, at the
    +current parameter value. MLlib includes gradient classes for common loss
    +functions, e.g., hinge, logistic, least-squares.  The gradient class takes as
    +input a training example, its label, and the current parameter value. 
    +* `updater` is a class that computes the gradient and loss of objective function 
    +of the regularization part for L-BFGS. MLlib includes updaters for cases without 
    +regularization, as well as L2 regularizer. 
    +* `numCorrections` is the number of corrections used in the L-BFGS update. 10 is 
    +recommended.
    +* `maxNumIterations` is the maximal number of iterations that L-BFGS can be run.
    +* `regParam` is the regularization parameter when using regularization.
    +
    +
    --- End diff --
    
    Remove extra empty line.


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/702#issuecomment-42619672
  
    Merged build started. 


---
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.
---

[GitHub] spark pull request: L-BFGS Documentation

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/702#discussion_r12501445
  
    --- Diff: docs/mllib-optimization.md ---
    @@ -163,3 +171,108 @@ each iteration, to compute the gradient direction.
     Available algorithms for gradient descent:
     
     * [GradientDescent.runMiniBatchSGD](api/mllib/index.html#org.apache.spark.mllib.optimization.GradientDescent)
    +
    +### Limited-memory BFGS
    +L-BFGS is currently only a low-level optimization primitive in `MLlib`. If you want to use L-BFGS in various 
    +ML algorithms such as Linear Regression, and Logistic Regression, you have to pass the gradient of objective
    +function, and updater into optimizer yourself instead of using the training APIs like 
    +[LogisticRegression.LogisticRegressionWithSGD](api/mllib/index.html#org.apache.spark.mllib.classification.LogisticRegressionWithSGD).
    --- End diff --
    
    `[LogisticRegression.LogisticRegressionWithSGD]` -> `[LogisticRegressionWithSGD]


---
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.
---