Tensorflow.js tf.metrics.recall() Function
Last Updated :
23 Jul, 2021
Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment.
The tf.metrics.recall() function is used to compute the recall of the predictions with respect to the labels. ‘Recall’ is one of the metrics in machine learning. You can read more about it here.
Syntax:
tf.metrics.recall (yTrue, yPred)
Parameters:
- yTrue (tensor): It contains the truth values either 0 or 1.
- yPred (tensor): It contains the predicted values only 0 or 1.
Return Value: It returns a tensor (tf.tensor).
Example 1:
Javascript
const tf = require( "@tensorflow/tfjs" )
const yTrue = tf.tensor2d([
[0, 0, 1, 1],
[0, 1, 0, 0],
[0, 0, 0, 1]
]);
const yPred = tf.tensor2d([
[1, 0, 0, 1],
[0, 1, 0, 0],
[1, 0, 1, 1]
]);
const recallResult = tf.metrics.recall(yTrue, yPred);
recallResult.print();
|
Output:
Tensor
0.75
Example 2:
Javascript
const tf = require( "@tensorflow/tfjs" )
const trueValues = tf.tensor2d([
[0, 0, 0],
[1, 0, 0],
[0, 1, 0]
]);
const predValues = tf.tensor2d([
[0, 1, 0],
[0, 0, 1],
[0, 1, 1]
]);
const recallResult = tf.metrics.recall(trueValues, predValues);
recallResult.print();
|
Output:
Tensor
0.5
Reference: https://js.tensorflow.org/api/latest/#metrics.recall
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...