jsat.lossfunctions
Class AbsoluteLoss
- java.lang.Object
-
- jsat.lossfunctions.AbsoluteLoss
-
public class AbsoluteLoss extends java.lang.Object implements LossR
The AbsoluteLoss loss function for regression L(x, y) = |x-y|.
This function is only one differentiable.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description AbsoluteLoss()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description AbsoluteLossclone()static doublederiv(double pred, double y)Returns the derivative of the absolute lossdoublegetConjugate(double b, double pred, double y)Computes the result of the conjugate function of this loss.doublegetDeriv(double pred, double y)Computes the first derivative of the getLoss function.doublegetDeriv2(double pred, double y)Computes the second derivative of the getLoss function.doublegetDeriv2Max()Returns an upper bound on the maximum value of the second derivative.doublegetLoss(double pred, double y)Computes the getLoss for a regression problem.doublegetRegression(double score)Given the score value of a data point, this returns the correct numeric result.doublelipschitz()If this loss is L-Lipschitz (1/L Lipschitz smooth), this method will return the value of L.static doubleloss(double pred, double y)Computes the absolute lossstatic doubleregress(double score)
-
-
-
Method Detail
-
loss
public static double loss(double pred, double y)Computes the absolute loss- Parameters:
pred- the predicted valuey- the target value- Returns:
- the loss for the functions
-
deriv
public static double deriv(double pred, double y)Returns the derivative of the absolute loss- Parameters:
pred- the predicted valuey- the target value- Returns:
- the derivative of the loss function
-
regress
public static double regress(double score)
-
getLoss
public double getLoss(double pred, double y)Description copied from interface:LossRComputes the getLoss for a regression problem.
-
getDeriv
public double getDeriv(double pred, double y)Description copied from interface:LossRComputes the first derivative of the getLoss function.
-
getDeriv2
public double getDeriv2(double pred, double y)Description copied from interface:LossRComputes the second derivative of the getLoss function.
-
getConjugate
public double getConjugate(double b, double pred, double y)Description copied from interface:LossFuncComputes the result of the conjugate function of this loss. This function is generally optional, and should returnDouble.NaNif not properly implemented. Many optimization algorithms do require a working implementation though.- Specified by:
getConjugatein interfaceLossFunc- Parameters:
b- the primary input to the functionpred- the predicted score in (-Infinity, Infinity)y- the true class label in {-1, 1}- Returns:
- the result of the conjugate function of this loss
-
getDeriv2Max
public double getDeriv2Max()
Description copied from interface:LossFuncReturns an upper bound on the maximum value of the second derivative. If the second derivative does not exist,Double.NaNis a valid result. It is also possible for0andDouble.POSITIVE_INFINITYto be valid results, and must be checked for.- Specified by:
getDeriv2Maxin interfaceLossFunc- Returns:
- the max value of
LossFunc.getDeriv2(double, double)
-
clone
public AbsoluteLoss clone()
-
getRegression
public double getRegression(double score)
Description copied from interface:LossRGiven the score value of a data point, this returns the correct numeric result. For most regression problems this simply returns the score value.- Specified by:
getRegressionin interfaceLossR- Parameters:
score- the score for a data point- Returns:
- the correct numeric regression value for this loss function
-
lipschitz
public double lipschitz()
Description copied from interface:LossFuncIf this loss is L-Lipschitz (1/L Lipschitz smooth), this method will return the value of L. If it is not L-Lipschitz, a value of 0 will be returned.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG