Class L1Updater

Object
org.apache.spark.mllib.optimization.Updater
org.apache.spark.mllib.optimization.L1Updater
All Implemented Interfaces:
Serializable, scala.Serializable

public class L1Updater extends Updater
Updater for L1 regularized problems. R(w) = ||w||_1 Uses a step-size decreasing with the square root of the number of iterations.

Instead of subgradient of the regularizer, the proximal operator for the L1 regularization is applied after the gradient step. This is known to result in better sparsity of the intermediate solution.

The corresponding proximal operator for the L1 norm is the soft-thresholding function. That is, each weight component is shrunk towards 0 by shrinkageVal.

If w is greater than shrinkageVal, set weight component to w-shrinkageVal. If w is less than -shrinkageVal, set weight component to w+shrinkageVal. If w is (-shrinkageVal, shrinkageVal), set weight component to 0.

Equivalently, set weight component to signum(w) * max(0.0, abs(w) - shrinkageVal)

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    scala.Tuple2<Vector,Object>
    compute(Vector weightsOld, Vector gradient, double stepSize, int iter, double regParam)
    Compute an updated value for weights given the gradient, stepSize, iteration number and regularization parameter.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • L1Updater

      public L1Updater()
  • Method Details

    • compute

      public scala.Tuple2<Vector,Object> compute(Vector weightsOld, Vector gradient, double stepSize, int iter, double regParam)
      Description copied from class: Updater
      Compute an updated value for weights given the gradient, stepSize, iteration number and regularization parameter. Also returns the regularization value regParam * R(w) computed using the *updated* weights.

      Specified by:
      compute in class Updater
      Parameters:
      weightsOld - - Column matrix of size dx1 where d is the number of features.
      gradient - - Column matrix of size dx1 where d is the number of features.
      stepSize - - step size across iterations
      iter - - Iteration number
      regParam - - Regularization parameter

      Returns:
      A tuple of 2 elements. The first element is a column matrix containing updated weights, and the second element is the regularization value computed using updated weights.