Invalid AUC curve value "%s".
Package:
tensorflow
158813

Exception Class:
ValueError
Raise code
@staticmethod
def from_str(key):
if key in ('pr', 'PR'):
return AUCCurve.PR
elif key in ('roc', 'ROC'):
return AUCCurve.ROC
else:
raise ValueError('Invalid AUC curve value "%s".' % key)
class AUCSummationMethod(Enum):
"""Type of AUC summation method.
https://en.wikipedia.org/wiki/Riemann_sum)
"""
Links to the raise (1)
https://github.com/tensorflow/tensorflow/blob/f26800a1e5b1199cfc1a5aca916edc836b541687/tensorflow/python/keras/utils/metrics_utils.py#L218See also in the other packages (1)
(❌️ No answer)
keras/invalid-auc-curve-value-s/
Ways to fix
When instantiating AUC
class to calculate approximate AUC (Area under the curve) of the ROC or PR curves the valid values for parameter curve
are ROC
or PR.
Reproducing the error:
pipenv install tensorflow
import tensorflow as tf
m = tf.keras.metrics.AUC(num_thresholds=3,
curve='RC' # typo error in RC. it should be ROC
)
m.update_state([0, 0, 1, 1], [0, 0.5, 0.3, 0.9])
print(m.result().numpy())
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-38-940549c09add> in <module>()
1 import tensorflow as tf
----> 2 m = tf.keras.metrics.AUC(num_thresholds=3,curve='RC')
3 m.update_state([0, 0, 1, 1], [0, 0.5, 0.3, 0.9])
4
5 print(m.result().numpy())
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/metrics.py in __init__(self, num_thresholds, curve, summation_method, name, dtype, thresholds, multi_label, num_labels, label_weights, from_logits)
2101 self.curve = curve
2102 else:
-> 2103 self.curve = metrics_utils.AUCCurve.from_str(curve)
2104 if isinstance(summation_method, metrics_utils.AUCSummationMethod):
2105 self.summation_method = summation_method
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/utils/metrics_utils.py in from_str(key)
214 return AUCCurve.ROC
215 else:
--> 216 raise ValueError('Invalid AUC curve value "%s".' % key)
217
218
ValueError: Invalid AUC curve value "RC".
Fix
The valid value are ROC and PR.
import tensorflow as tf
m = tf.keras.metrics.AUC(num_thresholds=3,
curve='ROC'
)
m.update_state([0, 0, 1, 1], [0, 0.5, 0.3, 0.9])
print(m.result().numpy())
0.75
Add a possible fix
Please authorize to post fix