org.apache.mahout.classifier.sgd
Class L1
java.lang.Object
org.apache.mahout.classifier.sgd.L1
- All Implemented Interfaces:
- org.apache.hadoop.io.Writable, PriorFunction
public class L1
- extends Object
- implements PriorFunction
Implements the Laplacian or bi-exponential prior. This prior has a strong tendency to set coefficients to zero
and thus is useful as an alternative to variable selection. This version implements truncation which prevents
a coefficient from changing sign. If a correction would change the sign, the coefficient is truncated to zero.
Note that it doesn't matter to have a scale for this distribution because after taking the derivative of the logP,
the lambda coefficient used to combine the prior with the observations has the same effect. If we had a scale here,
then it would be the same effect as just changing lambda.
Method Summary |
double |
age(double oldValue,
double generations,
double learningRate)
Applies the regularization to a coefficient. |
double |
logP(double betaIJ)
Returns the log of the probability of a particular coefficient value according to the prior. |
void |
readFields(DataInput dataInput)
|
void |
write(DataOutput out)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
L1
public L1()
age
public double age(double oldValue,
double generations,
double learningRate)
- Description copied from interface:
PriorFunction
- Applies the regularization to a coefficient.
- Specified by:
age
in interface PriorFunction
- Parameters:
oldValue
- The previous value.generations
- The number of generations.learningRate
- The learning rate with lambda baked in.
- Returns:
- The new coefficient value after regularization.
logP
public double logP(double betaIJ)
- Description copied from interface:
PriorFunction
- Returns the log of the probability of a particular coefficient value according to the prior.
- Specified by:
logP
in interface PriorFunction
- Parameters:
betaIJ
- The coefficient.
- Returns:
- The log probability.
write
public void write(DataOutput out)
throws IOException
- Specified by:
write
in interface org.apache.hadoop.io.Writable
- Throws:
IOException
readFields
public void readFields(DataInput dataInput)
throws IOException
- Specified by:
readFields
in interface org.apache.hadoop.io.Writable
- Throws:
IOException
Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.