public class L1Regularization$ extends Object implements RegularizationPenalty
L_1
regularization penalty.
The regularization function is the L1
norm ||w||_1
with w
being the weight vector.
The L_1
penalty can be used to drive a number of the solution coefficients to 0, thereby
producing sparse solutions.
Modifier and Type | Field and Description |
---|---|
static L1Regularization$ |
MODULE$
Static reference to the singleton instance of this Scala object.
|
Constructor and Description |
---|
L1Regularization$() |
Modifier and Type | Method and Description |
---|---|
double |
regLoss(double oldLoss,
Vector weightVector,
double regularizationConstant)
Adds regularization to the loss value
|
Vector |
takeStep(Vector weightVector,
Vector gradient,
double regularizationConstant,
double learningRate)
Calculates the new weights based on the gradient and L1 regularization penalty
|
public static final L1Regularization$ MODULE$
public Vector takeStep(Vector weightVector, Vector gradient, double regularizationConstant, double learningRate)
Uses the proximal gradient method with L1 regularization to update weights.
The updated weight w - learningRate * gradient
is shrunk towards zero
by applying the proximal operator signum(w) * max(0.0, abs(w) - shrinkageVal)
where w
is the weight vector, lambda
is the regularization parameter,
and shrinkageVal
is lambda*learningRate
.
takeStep
in interface RegularizationPenalty
weightVector
- The weights to be updatedgradient
- The gradient according to which we will update the weightsregularizationConstant
- The regularization parameter to be appliedlearningRate
- The effective step size for this iterationpublic double regLoss(double oldLoss, Vector weightVector, double regularizationConstant)
The updated loss is oldLoss + lambda * ||w||_1
where
w
is the weight vector and lambda
is the regularization parameter
regLoss
in interface RegularizationPenalty
oldLoss
- The loss to be updatedweightVector
- The weights used to update the lossregularizationConstant
- The regularization parameter to be appliedCopyright © 2014–2018 The Apache Software Foundation. All rights reserved.