jsat.lossfunctions
Interface LossFunc
-
- All Superinterfaces:
- java.io.Serializable
- All Known Implementing Classes:
- AbsoluteLoss, EpsilonInsensitiveLoss, HingeLoss, HuberLoss, LogisticLoss, SoftmaxLoss, SquaredLoss
public interface LossFunc extends java.io.SerializableProvides a generic interface for some loss function on some problem that can be described with a single real prediction value and a single real expected value.
A loss function must be non-negative and should be convex.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description LossFuncclone()doublegetConjugate(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 loss 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 loss for some problem.doublelipschitz()If this loss is L-Lipschitz (1/L Lipschitz smooth), this method will return the value of L.
-
-
-
Method Detail
-
getLoss
double getLoss(double pred, double y)Computes the loss for some problem.- Parameters:
pred- the predicted value in (-Infinity, Infinity)y- the true value in (-Infinity, Infinity)- Returns:
- the loss in [0, Inf)
-
getDeriv
double getDeriv(double pred, double y)Computes the first derivative of the loss function.- Parameters:
pred- the predicted score in (-Infinity, Infinity)y- the true value in (-Infinity, Infinity)- Returns:
- the first derivative of the getLoss
-
getDeriv2
double getDeriv2(double pred, double y)Computes the second derivative of the getLoss function.- Parameters:
pred- the predicted score in (-Infinity, Infinity)y- the true value in (-Infinity, Infinity)- Returns:
- the second derivative of the getLoss function
-
getConjugate
double getConjugate(double b, double pred, double y)Computes 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.- 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
double getDeriv2Max()
Returns 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.- Returns:
- the max value of
getDeriv2(double, double)
-
lipschitz
double lipschitz()
If 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.- Returns:
- the L-Lipschitz constant, or 0 if this loss is not L-Lipschitz;
-
clone
LossFunc clone()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG