Class BinaryAccuracy


public class BinaryAccuracy extends AbstractAccuracy
BinaryAccuracy is the AbstractAccuracy with two classes.

It is assumed that the classes are identified with a labels array of 0s and 1s and a prediction array where values above the threshold are the positive (1) examples and values below the threshold are the negative (0) examples. If you have a different encoding, you may want to look at the Accuracy.

  • Constructor Details

    • BinaryAccuracy

      public BinaryAccuracy(String name, float threshold, int axis)
      Creates a binary (two class) accuracy evaluator.
      Parameters:
      name - the name of the evaluator, default is "Accuracy"
      threshold - the value differentiating the posive and negative classes (usually 0 or .5)
      axis - the axis that represent classes in prediction, default 1
    • BinaryAccuracy

      public BinaryAccuracy(String name, float threshold)
      Creates a binary (two class) accuracy evaluator that computes accuracy across axis 1 along given index.
      Parameters:
      name - the name of the evaluator, default is "Accuracy"
      threshold - the value differentiating the posive and negative classes (usually 0 or .5)
    • BinaryAccuracy

      public BinaryAccuracy(float threshold)
      Creates a binary (two class) accuracy evaluator that computes accuracy across axis 1 along the 0th index.
      Parameters:
      threshold - the value differentiating the posive and negative classes (usually 0 or .5)
    • BinaryAccuracy

      public BinaryAccuracy()
      Creates a binary (two class) accuracy evaluator with 0 threshold.
  • Method Details

    • accuracyHelper

      protected ai.djl.util.Pair<Long,NDArray> accuracyHelper(NDList labels, NDList predictions)
      A helper for classes extending AbstractAccuracy.
      Specified by:
      accuracyHelper in class AbstractAccuracy
      Parameters:
      labels - the labels to get accuracy for
      predictions - the predictions to get accuracy for
      Returns:
      a pair(number of total values, ndarray int of correct values)