9

Invalid AUC curve value "%s".

Package:
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)
"""``````
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

2

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)
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
```

Jul 16, 2021
kellemnegasi 31.6k