The way to add the ROC AUC as a metric on your Tensorflow / Keras project is to copy this function that computes the ROC AUC and use the function name in the model. The function only requires a little customized tf code.
To use the function in the model. We first need to compile with the function passed directly and not a string (as it is shown in the example below).
Then we can use it in the callbacks but we need to refer to it as a string (so this time between the “” as shown in the snippet below).
Other customized functions follow the same pattern.
The function tf.keras.metrics.AUC already implements the Area Under the Curve natively in TensorFlow in the Keras module. You can check the documentation for further information in this regard.