Class Gradient

Object
org.apache.spark.mllib.optimization.Gradient
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
HingeGradient, LeastSquaresGradient, LogisticGradient

public abstract class Gradient extends Object implements Serializable
Class used to compute the gradient for a loss function, given a single data point.
See Also:
  • 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.
    abstract 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

    • Gradient

      public Gradient()
  • Method Details

    • compute

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

      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 abstract 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.

      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