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
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.
-
Field Summary
Fields inherited from class ai.djl.training.evaluator.AbstractAccuracy
axis, correctInstancesFields inherited from class ai.djl.training.evaluator.Evaluator
totalInstances -
Constructor Summary
ConstructorsConstructorDescriptionCreates 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(String name, float threshold) Creates a binary (two class) accuracy evaluator that computes accuracy across axis 1 along given index.BinaryAccuracy(String name, float threshold, int axis) Creates a binary (two class) accuracy evaluator. -
Method Summary
Modifier and TypeMethodDescriptionaccuracyHelper(NDList labels, NDList predictions) A helper for classes extendingAbstractAccuracy.Methods inherited from class ai.djl.training.evaluator.AbstractAccuracy
addAccumulator, evaluate, getAccumulator, resetAccumulator, updateAccumulator, updateAccumulatorsMethods inherited from class ai.djl.training.evaluator.Evaluator
checkLabelShapes, checkLabelShapes, getName
-
Constructor Details
-
BinaryAccuracy
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
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
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)
-