Package ai.djl.training.evaluator
Class BinaryAccuracy
- java.lang.Object
-
- ai.djl.training.evaluator.Evaluator
-
- ai.djl.training.evaluator.AbstractAccuracy
-
- ai.djl.training.evaluator.BinaryAccuracy
-
public class BinaryAccuracy extends AbstractAccuracy
BinaryAccuracyis theAbstractAccuracywith 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.
-
-
Field Summary
-
Fields inherited from class ai.djl.training.evaluator.AbstractAccuracy
axis, correctInstances
-
Fields inherited from class ai.djl.training.evaluator.Evaluator
totalInstances
-
-
Constructor Summary
Constructors Constructor Description BinaryAccuracy()Creates a binary (two class) accuracy evaluator with 0 threshold.BinaryAccuracy(float threshold)Creates a binary (two class) accuracy evaluator that computes accuracy across axis 1 along the 0th index.BinaryAccuracy(java.lang.String name, float threshold)Creates a binary (two class) accuracy evaluator that computes accuracy across axis 1 along given index.BinaryAccuracy(java.lang.String name, float threshold, int axis)Creates a binary (two class) accuracy evaluator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ai.djl.util.Pair<java.lang.Long,NDArray>accuracyHelper(NDList labels, NDList predictions)A helper for classes extendingAbstractAccuracy.-
Methods inherited from class ai.djl.training.evaluator.AbstractAccuracy
addAccumulator, evaluate, getAccumulator, resetAccumulator, updateAccumulator
-
Methods inherited from class ai.djl.training.evaluator.Evaluator
checkLabelShapes, checkLabelShapes, getName
-
-
-
-
Constructor Detail
-
BinaryAccuracy
public BinaryAccuracy(java.lang.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(java.lang.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 Detail
-
accuracyHelper
protected ai.djl.util.Pair<java.lang.Long,NDArray> accuracyHelper(NDList labels, NDList predictions)
A helper for classes extendingAbstractAccuracy.- Specified by:
accuracyHelperin classAbstractAccuracy- Parameters:
labels- the labels to get accuracy forpredictions- the predictions to get accuracy for- Returns:
- a pair(number of total values, ndarray int of correct values)
-
-