Class HingeGradient

Object
org.apache.spark.mllib.optimization.Gradient
org.apache.spark.mllib.optimization.HingeGradient
All Implemented Interfaces:
Serializable, scala.Serializable

public class HingeGradient extends Gradient
Compute gradient and loss for a Hinge loss function, as used in SVM binary classification. See also the documentation for the precise formulation.

See Also:
Note:
This assumes that the labels are {0,1}
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    scala.Tuple2<Vector,Object>
    compute(Vector data, double label, Vector weights)
    Compute the gradient and loss given the features of a single data point.
    double
    compute(Vector data, double label, Vector weights, Vector cumGradient)
    Compute the gradient and loss given the features of a single data point, add the gradient to a provided vector to avoid creating new objects, and return loss.

    Methods inherited from class java.lang.Object

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

    • HingeGradient

      public HingeGradient()
  • Method Details

    • compute

      public scala.Tuple2<Vector,Object> compute(Vector data, double label, Vector weights)
      Description copied from class: Gradient
      Compute the gradient and loss given the features of a single data point.

      Overrides:
      compute in class Gradient
      Parameters:
      data - features for one data point
      label - label for this data point
      weights - weights/coefficients corresponding to features

      Returns:
      (gradient: Vector, loss: Double)
    • compute

      public double compute(Vector data, double label, Vector weights, Vector cumGradient)
      Description copied from class: Gradient
      Compute the gradient and loss given the features of a single data point, add the gradient to a provided vector to avoid creating new objects, and return loss.

      Specified by:
      compute in class Gradient
      Parameters:
      data - features for one data point
      label - label for this data point
      weights - weights/coefficients corresponding to features
      cumGradient - the computed gradient will be added to this vector

      Returns:
      loss