jsat.lossfunctions
Class LogisticLoss
- java.lang.Object
-
- jsat.lossfunctions.LogisticLoss
-
- Direct Known Subclasses:
- SoftmaxLoss
public class LogisticLoss extends java.lang.Object implements LossC
The LogisticLoss loss function for classification L(x, y) = log(1+exp(-y*x)).
This function is twice differentiable.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description LogisticLoss()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static CategoricalResultsclassify(double score)LogisticLossclone()static doublederiv(double pred, double y)Computes the first derivative of the logistic lossstatic doublederiv2(double pred, double y)Computes the second derivative of the logistic lossCategoricalResultsgetClassification(double score)Given the score value of a data point, this returns the classification results.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 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 classification problem.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 logistic loss
-
-
-
Method Detail
-
loss
public static double loss(double pred, double y)Computes the logistic loss- Parameters:
pred- the predicted valuey- the true value- Returns:
- the logistic loss
-
deriv
public static double deriv(double pred, double y)Computes the first derivative of the logistic loss- Parameters:
pred- the predicted valuey- the true value- Returns:
- the first derivative of the logistic loss
-
deriv2
public static double deriv2(double pred, double y)Computes the second derivative of the logistic loss- Parameters:
pred- the predicted valuey- the true value- Returns:
- the second derivative of the logistic loss
-
classify
public static CategoricalResults classify(double score)
-
getLoss
public double getLoss(double pred, double y)Description copied from interface:LossCComputes the getLoss for a classification problem.
-
getDeriv
public double getDeriv(double pred, double y)Description copied from interface:LossCComputes the first derivative of the getLoss function.
-
getDeriv2
public double getDeriv2(double pred, double y)Description copied from interface:LossCComputes the second derivative of the getLoss function.
-
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 LogisticLoss clone()
-
getClassification
public CategoricalResults getClassification(double score)
Description copied from interface:LossCGiven the score value of a data point, this returns the classification results.- Specified by:
getClassificationin interfaceLossC- Parameters:
score- the score for a data point- Returns:
- the categorical results with the correct probability values for this loss 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
-
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