Binary accuracy metric function.
yTrue and yPred can have 0-1 values. Example:
yTrue
yPred
const x = tf.tensor2d([[1, 1, 1, 1], [0, 0, 0, 0]], [2, 4]);const y = tf.tensor2d([[1, 0, 1, 0], [0, 0, 0, 1]], [2, 4]);const accuracy = tf.metrics.binaryAccuracy(x, y);accuracy.print(); Copy
const x = tf.tensor2d([[1, 1, 1, 1], [0, 0, 0, 0]], [2, 4]);const y = tf.tensor2d([[1, 0, 1, 0], [0, 0, 0, 1]], [2, 4]);const accuracy = tf.metrics.binaryAccuracy(x, y);accuracy.print();
yTrue and yPred can also have floating-number values between 0 and 1, in which case the values will be thresholded at 0.5 to yield 0-1 values (i.e., a value >= 0.5 and <= 1.0 is interpreted as 1).
Example:
const x = tf.tensor1d([1, 1, 1, 1, 0, 0, 0, 0]);const y = tf.tensor1d([0.2, 0.4, 0.6, 0.8, 0.2, 0.3, 0.4, 0.7]);const accuracy = tf.metrics.binaryAccuracy(x, y);accuracy.print(); Copy
const x = tf.tensor1d([1, 1, 1, 1, 0, 0, 0, 0]);const y = tf.tensor1d([0.2, 0.4, 0.6, 0.8, 0.2, 0.3, 0.4, 0.7]);const accuracy = tf.metrics.binaryAccuracy(x, y);accuracy.print();
Binary Tensor of truth.
Binary Tensor of prediction.
Accuracy Tensor.
Generated using TypeDoc
Binary accuracy metric function.
yTrue
andyPred
can have 0-1 values. Example:yTrue
andyPred
can also have floating-number values between 0 and 1, in which case the values will be thresholded at 0.5 to yield 0-1 values (i.e., a value >= 0.5 and <= 1.0 is interpreted as 1).Example: