# Module: tf.keras.metrics

<br />

|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/keras/metrics) |

Built-in metrics.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.keras.metrics`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/keras/metrics)

<br />

## Classes

[`class AUC`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/AUC): Computes the approximate AUC (Area under the curve) via a Riemann sum.

[`class Accuracy`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/Accuracy): Calculates how often predictions matches labels.

[`class BinaryAccuracy`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/BinaryAccuracy): Calculates how often predictions matches labels.

[`class BinaryCrossentropy`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/BinaryCrossentropy): Computes the crossentropy metric between the labels and predictions.

[`class CategoricalAccuracy`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/CategoricalAccuracy): Calculates how often predictions matches labels.

[`class CategoricalCrossentropy`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/CategoricalCrossentropy): Computes the crossentropy metric between the labels and predictions.

[`class CategoricalHinge`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/CategoricalHinge): Computes the categorical hinge metric between `y_true` and `y_pred`.

[`class CosineSimilarity`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/CosineSimilarity): Computes the cosine similarity between the labels and predictions.

[`class FalseNegatives`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/FalseNegatives): Calculates the number of false negatives.

[`class FalsePositives`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/FalsePositives): Calculates the number of false positives.

[`class Hinge`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/Hinge): Computes the hinge metric between `y_true` and `y_pred`.

[`class KLDivergence`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/KLDivergence): Computes Kullback-Leibler divergence metric between `y_true` and `y_pred`.

[`class LogCoshError`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/LogCoshError): Computes the logarithm of the hyperbolic cosine of the prediction error.

[`class Mean`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/Mean): Computes the (weighted) mean of the given values.

[`class MeanAbsoluteError`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/MeanAbsoluteError): Computes the mean absolute error between the labels and predictions.

[`class MeanAbsolutePercentageError`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/MeanAbsolutePercentageError): Computes the mean absolute percentage error between `y_true` and `y_pred`.

[`class MeanIoU`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/MeanIoU): Computes the mean Intersection-Over-Union metric.

[`class MeanRelativeError`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/MeanRelativeError): Computes the mean relative error by normalizing with the given values.

[`class MeanSquaredError`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/MeanSquaredError): Computes the mean squared error between `y_true` and `y_pred`.

[`class MeanSquaredLogarithmicError`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/MeanSquaredLogarithmicError): Computes the mean squared logarithmic error between `y_true` and `y_pred`.

[`class MeanTensor`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/MeanTensor): Computes the element-wise (weighted) mean of the given tensors.

[`class Metric`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/Metric): Encapsulates metric logic and state.

[`class Poisson`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/Poisson): Computes the Poisson metric between `y_true` and `y_pred`.

[`class Precision`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/Precision): Computes the precision of the predictions with respect to the labels.

[`class Recall`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/Recall): Computes the recall of the predictions with respect to the labels.

[`class RootMeanSquaredError`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/RootMeanSquaredError): Computes root mean squared error metric between `y_true` and `y_pred`.

[`class SensitivityAtSpecificity`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/SensitivityAtSpecificity): Computes the sensitivity at a given specificity.

[`class SparseCategoricalAccuracy`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/SparseCategoricalAccuracy): Calculates how often predictions matches integer labels.

[`class SparseCategoricalCrossentropy`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/SparseCategoricalCrossentropy): Computes the crossentropy metric between the labels and predictions.

[`class SparseTopKCategoricalAccuracy`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/SparseTopKCategoricalAccuracy): Computes how often integer targets are in the top `K` predictions.

[`class SpecificityAtSensitivity`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/SpecificityAtSensitivity): Computes the specificity at a given sensitivity.

[`class SquaredHinge`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/SquaredHinge): Computes the squared hinge metric between `y_true` and `y_pred`.

[`class Sum`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/Sum): Computes the (weighted) sum of the given values.

[`class TopKCategoricalAccuracy`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/TopKCategoricalAccuracy): Computes how often targets are in the top `K` predictions.

[`class TrueNegatives`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/TrueNegatives): Calculates the number of true negatives.

[`class TruePositives`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/TruePositives): Calculates the number of true positives.

## Functions

[`KLD(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/KLD): Computes Kullback-Leibler divergence loss between `y_true` and `y_pred`.

[`MAE(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MAE)

[`MAPE(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MAPE)

[`MSE(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MSE)

[`MSLE(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MSLE)

[`binary_accuracy(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/binary_accuracy)

[`binary_crossentropy(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/binary_crossentropy)

[`categorical_accuracy(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/categorical_accuracy)

[`categorical_crossentropy(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/categorical_crossentropy): Computes the categorical crossentropy loss.

[`cosine(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/cosine): Computes the cosine similarity between labels and predictions.

[`cosine_proximity(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/cosine): Computes the cosine similarity between labels and predictions.

[`deserialize(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/deserialize)

[`get(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/get)

[`hinge(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/hinge): Computes the hinge loss between `y_true` and `y_pred`.

[`kld(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/KLD): Computes Kullback-Leibler divergence loss between `y_true` and `y_pred`.

[`kullback_leibler_divergence(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/KLD): Computes Kullback-Leibler divergence loss between `y_true` and `y_pred`.

[`mae(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MAE)

[`mape(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MAPE)

[`mean_absolute_error(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MAE)

[`mean_absolute_percentage_error(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MAPE)

[`mean_squared_error(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MSE)

[`mean_squared_logarithmic_error(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MSLE)

[`mse(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MSE)

[`msle(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/MSLE)

[`poisson(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/poisson): Computes the Poisson loss between y_true and y_pred.

[`serialize(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/serialize)

[`sparse_categorical_accuracy(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/sparse_categorical_accuracy)

[`sparse_categorical_crossentropy(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/sparse_categorical_crossentropy)

[`sparse_top_k_categorical_accuracy(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/sparse_top_k_categorical_accuracy)

[`squared_hinge(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/losses/squared_hinge): Computes the squared hinge loss between `y_true` and `y_pred`.

[`top_k_categorical_accuracy(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/metrics/top_k_categorical_accuracy)