java.lang.Object
org.tribuo.classification.sgd.objectives.Hinge
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>, LabelObjective, SGDObjective<Integer>

public class Hinge extends Object implements LabelObjective
Hinge loss, scores the correct value margin and any incorrect predictions -margin. By default the margin is 1.0.

The Hinge loss does not generate a probabilistic model, and uses a NoopNormalizer.

  • Constructor Details

    • Hinge

      public Hinge(double margin)
      Construct a hinge objective with the supplied margin.
      Parameters:
      margin - The margin to use.
    • Hinge

      public Hinge()
      Construct a hinge objective with a margin of 1.0.
  • Method Details

    • valueAndGradient

      @Deprecated public com.oracle.labs.mlrg.olcut.util.Pair<Double,SGDVector> valueAndGradient(int truth, SGDVector prediction)
      Deprecated.
      Description copied from interface: LabelObjective
      Scores a prediction, returning the loss and a vector of per label gradients.
      Specified by:
      valueAndGradient in interface LabelObjective
      Parameters:
      truth - The true label id.
      prediction - The prediction for each label id.
      Returns:
      The score and per label gradient.
    • lossAndGradient

      public com.oracle.labs.mlrg.olcut.util.Pair<Double,SGDVector> lossAndGradient(Integer truth, SGDVector prediction)
      Returns a Pair of Double and SGDVector representing the loss and per label gradients respectively.
      Specified by:
      lossAndGradient in interface LabelObjective
      Specified by:
      lossAndGradient in interface SGDObjective<Integer>
      Parameters:
      truth - The true label id.
      prediction - The prediction for each label id.
      Returns:
      The loss and per label gradient.
    • getNormalizer

      public VectorNormalizer getNormalizer()
      Returns a new NoopNormalizer.
      Specified by:
      getNormalizer in interface LabelObjective
      Returns:
      The vector normalizer.
    • isProbabilistic

      public boolean isProbabilistic()
      Returns false.
      Specified by:
      isProbabilistic in interface LabelObjective
      Returns:
      False.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getProvenance

      public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>