# Module: tf.keras.metrics

<br />

#### View aliases


**Main aliases**

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

<br />

## Modules

[`experimental`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/experimental) module

## Classes

[`class AUC`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/AUC): Approximates the AUC (Area under the curve) of the ROC or PR curves.

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

[`class BinaryAccuracy`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/BinaryAccuracy): Calculates how often predictions match binary labels.

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

[`class BinaryIoU`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/BinaryIoU): Computes the Intersection-Over-Union metric for class 0 and/or 1.

[`class CategoricalAccuracy`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/CategoricalAccuracy): Calculates how often predictions match one-hot labels.

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

[`class CategoricalHinge`](https://www.tensorflow.org/versions/r2.14/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/r2.14/api_docs/python/tf/keras/metrics/CosineSimilarity): Computes the cosine similarity between the labels and predictions.

[`class F1Score`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/F1Score): Computes F-1 Score.

[`class FBetaScore`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/FBetaScore): Computes F-Beta score.

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

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

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

[`class IoU`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/IoU): Computes the Intersection-Over-Union metric for specific target classes.

[`class KLDivergence`](https://www.tensorflow.org/versions/r2.14/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/r2.14/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/r2.14/api_docs/python/tf/keras/metrics/Mean): Computes the (weighted) mean of the given values.

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

[`class MeanAbsolutePercentageError`](https://www.tensorflow.org/versions/r2.14/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/r2.14/api_docs/python/tf/keras/metrics/MeanIoU): Computes the mean Intersection-Over-Union metric.

[`class MeanMetricWrapper`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/MeanMetricWrapper): Wraps a stateless metric function with the Mean metric.

[`class MeanRelativeError`](https://www.tensorflow.org/versions/r2.14/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/r2.14/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/r2.14/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/r2.14/api_docs/python/tf/keras/metrics/MeanTensor): Computes the element-wise (weighted) mean of the given tensors.

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

[`class OneHotIoU`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/OneHotIoU): Computes the Intersection-Over-Union metric for one-hot encoded labels.

[`class OneHotMeanIoU`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/OneHotMeanIoU): Computes mean Intersection-Over-Union metric for one-hot encoded labels.

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

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

[`class PrecisionAtRecall`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/PrecisionAtRecall): Computes best precision where recall is \>= specified value.

[`class R2Score`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/R2Score): Computes R2 score.

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

[`class RecallAtPrecision`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/RecallAtPrecision): Computes best recall where precision is \>= specified value.

[`class RootMeanSquaredError`](https://www.tensorflow.org/versions/r2.14/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/r2.14/api_docs/python/tf/keras/metrics/SensitivityAtSpecificity): Computes best sensitivity where specificity is \>= specified value.

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

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

[`class SparseTopKCategoricalAccuracy`](https://www.tensorflow.org/versions/r2.14/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/r2.14/api_docs/python/tf/keras/metrics/SpecificityAtSensitivity): Computes best specificity where sensitivity is \>= specified value.

[`class SquaredHinge`](https://www.tensorflow.org/versions/r2.14/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/r2.14/api_docs/python/tf/keras/metrics/Sum): Computes the (weighted) sum of the given values.

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

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

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

## Functions

[`KLD(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/kl_divergence): Computes Kullback-Leibler divergence loss between `y_true` \& `y_pred`.

[`MAE(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_absolute_error): Computes the mean absolute error between labels and predictions.

[`MAPE(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_absolute_percentage_error): Computes the mean absolute percentage error between `y_true` \& `y_pred`.

[`MSE(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_squared_error): Computes the mean squared error between labels and predictions.

[`MSLE(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_squared_logarithmic_error): Computes the mean squared logarithmic error between `y_true` \& `y_pred`.

[`binary_accuracy(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/binary_accuracy): Calculates how often predictions match binary labels.

[`binary_crossentropy(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/binary_crossentropy): Computes the binary crossentropy loss.

[`binary_focal_crossentropy(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/binary_focal_crossentropy): Computes the binary focal crossentropy loss.

[`categorical_accuracy(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/categorical_accuracy): Calculates how often predictions match one-hot labels.

[`categorical_crossentropy(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/categorical_crossentropy): Computes the categorical crossentropy loss.

[`categorical_focal_crossentropy(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/categorical_focal_crossentropy): Computes the categorical focal crossentropy loss.

[`deserialize(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/deserialize): Deserializes a serialized metric class/function instance.

[`get(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/get): Retrieves a Keras metric as a `function`/`Metric` class instance.

[`hinge(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/hinge): Computes the hinge loss between `y_true` \& `y_pred`.

[`kl_divergence(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/kl_divergence): Computes Kullback-Leibler divergence loss between `y_true` \& `y_pred`.

[`kld(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/kl_divergence): Computes Kullback-Leibler divergence loss between `y_true` \& `y_pred`.

[`kullback_leibler_divergence(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/kl_divergence): Computes Kullback-Leibler divergence loss between `y_true` \& `y_pred`.

[`log_cosh(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/losses/log_cosh): Logarithm of the hyperbolic cosine of the prediction error.

[`logcosh(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/losses/log_cosh): Logarithm of the hyperbolic cosine of the prediction error.

[`mae(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_absolute_error): Computes the mean absolute error between labels and predictions.

[`mape(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_absolute_percentage_error): Computes the mean absolute percentage error between `y_true` \& `y_pred`.

[`mean_absolute_error(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_absolute_error): Computes the mean absolute error between labels and predictions.

[`mean_absolute_percentage_error(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_absolute_percentage_error): Computes the mean absolute percentage error between `y_true` \& `y_pred`.

[`mean_squared_error(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_squared_error): Computes the mean squared error between labels and predictions.

[`mean_squared_logarithmic_error(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_squared_logarithmic_error): Computes the mean squared logarithmic error between `y_true` \& `y_pred`.

[`mse(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_squared_error): Computes the mean squared error between labels and predictions.

[`msle(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/mean_squared_logarithmic_error): Computes the mean squared logarithmic error between `y_true` \& `y_pred`.

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

[`serialize(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/serialize): Serializes metric function or `Metric` instance.

[`sparse_categorical_accuracy(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/sparse_categorical_accuracy): Calculates how often predictions match integer labels.

[`sparse_categorical_crossentropy(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/sparse_categorical_crossentropy): Computes the sparse categorical crossentropy loss.

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

[`squared_hinge(...)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/keras/metrics/squared_hinge): Computes the squared hinge loss between `y_true` \& `y_pred`.

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