Documentation of 'jsat.lossfunctions.SquaredLoss' Java class
SquaredLoss
jsat.lossfunctions

Class SquaredLoss

  • All Implemented Interfaces:
    java.io.Serializable, LossFunc, LossR


    public class SquaredLoss
    extends java.lang.Object
    implements LossR
    The SquaredLoss loss function for regression L(x, y) = (x-y)2.
    This function is twice differentiable.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      SquaredLoss() 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      SquaredLoss clone() 
      static double deriv(double pred, double y)
      Computes the first derivative of the squared loss
      static double deriv2(double pred, double y)
      Computes the second derivative of the squared loss, which is always 1
      double getConjugate(double b, double pred, double y)
      Computes the result of the conjugate function of this loss.
      double getDeriv(double pred, double y)
      Computes the first derivative of the getLoss function.
      double getDeriv2(double pred, double y)
      Computes the second derivative of the getLoss function.
      double getDeriv2Max()
      Returns an upper bound on the maximum value of the second derivative.
      double getLoss(double pred, double y)
      Computes the getLoss for a regression problem.
      double getRegression(double score)
      Given the score value of a data point, this returns the correct numeric result.
      double lipschitz()
      If this loss is L-Lipschitz (1/L Lipschitz smooth), this method will return the value of L.
      static double loss(double pred, double y)
      Computes the SquaredLoss loss
      static double regress(double score) 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SquaredLoss

        public SquaredLoss()
    • Method Detail

      • loss

        public static double loss(double pred,
                                  double y)
        Computes the SquaredLoss loss
        Parameters:
        pred - the predicted value
        y - the true value
        Returns:
        the squared loss
      • deriv

        public static double deriv(double pred,
                                   double y)
        Computes the first derivative of the squared loss
        Parameters:
        pred - the predicted value
        y - the true value
        Returns:
        the first derivative of the squared loss
      • deriv2

        public static double deriv2(double pred,
                                    double y)
        Computes the second derivative of the squared loss, which is always 1
        Parameters:
        pred - the predicted value
        y - the true value
        Returns:
        the second derivative of the squared loss
      • regress

        public static double regress(double score)
      • getLoss

        public double getLoss(double pred,
                              double y)
        Description copied from interface: LossR
        Computes the getLoss for a regression problem.
        Specified by:
        getLoss in interface LossFunc
        Specified by:
        getLoss in interface LossR
        Parameters:
        pred - the predicted value in (-Infinity, Infinity)
        y - the true target value in (-Infinity, Infinity)
        Returns:
        the getLoss in [0, Inf)
      • getDeriv

        public double getDeriv(double pred,
                               double y)
        Description copied from interface: LossR
        Computes the first derivative of the getLoss function.
        Specified by:
        getDeriv in interface LossFunc
        Specified by:
        getDeriv in interface LossR
        Parameters:
        pred - the predicted value in (-Infinity, Infinity)
        y - the true target value in (-Infinity, Infinity)
        Returns:
        the first derivative of the getLoss
      • getDeriv2

        public double getDeriv2(double pred,
                                double y)
        Description copied from interface: LossR
        Computes the second derivative of the getLoss function.
        Specified by:
        getDeriv2 in interface LossFunc
        Specified by:
        getDeriv2 in interface LossR
        Parameters:
        pred - the predicted value in (-Infinity, Infinity)
        y - the true target value in (-Infinity, Infinity)
        Returns:
        the second derivative of the getLoss function
      • getConjugate

        public double getConjugate(double b,
                                   double pred,
                                   double y)
        Description copied from interface: LossFunc
        Computes the result of the conjugate function of this loss. This function is generally optional, and should return Double.NaN if not properly implemented. Many optimization algorithms do require a working implementation though.
        Specified by:
        getConjugate in interface LossFunc
        Parameters:
        b - the primary input to the function
        pred - 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: LossFunc
        Returns an upper bound on the maximum value of the second derivative. If the second derivative does not exist, Double.NaN is a valid result. It is also possible for 0 and Double.POSITIVE_INFINITY to be valid results, and must be checked for.
        Specified by:
        getDeriv2Max in interface LossFunc
        Returns:
        the max value of LossFunc.getDeriv2(double, double)
      • getRegression

        public double getRegression(double score)
        Description copied from interface: LossR
        Given 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:
        getRegression in interface LossR
        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: LossFunc
        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.
        Specified by:
        lipschitz in interface LossFunc
        Returns:
        the L-Lipschitz constant, or 0 if this loss is not L-Lipschitz;

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.