keras-team/keras · error · ValueError

Invalid AUC summation method value

Error message

Invalid AUC summation method value: "{key}". Expected values are ["interpolation", "majoring", "minoring"]

What it means

AUC's summation_method controls how area under the curve is approximated. AUCSummationMethod.from_str() accepts only 'interpolation', 'majoring' or 'minoring' (case-insensitive) and raises this ValueError otherwise. Strings like 'trapezoid' or 'interpolate' are rejected.

Solutions

  1. Use exactly 'interpolation', 'majoring', or 'minoring'.
  2. Keep the default summation_method='interpolation' unless you specifically need Riemann majoring/minoring behavior.

Example fix

# before
auc = keras.metrics.AUC(summation_method='trapezoid')

# after
auc = keras.metrics.AUC(summation_method='interpolation')
Defensive patterns

Strategy: validation

Validate before calling

VALID_SUMMATION = {'interpolation', 'majoring', 'minoring'}
def check_summation(s):
    if s.lower() not in VALID_SUMMATION:
        raise ValueError(f'summation_method must be one of {sorted(VALID_SUMMATION)}')
    return s

Prevention

When it happens

Trigger: Calling keras.metrics.AUC(summation_method='trapezoid') or summation_method='interpolate' - anything other than the three accepted keys.

Common situations: Assuming numpy.trapz-style naming ('trapezoid') transfers to Keras; typos in hyperparameter configs.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/0c9cb875732877cb. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/metrics/metrics_utils.py:92

      summation for decreasing intervals.
    * 'majoring': Applies right summation for increasing intervals and left
      summation for decreasing intervals.
    """

    INTERPOLATION = "interpolation"
    MAJORING = "majoring"
    MINORING = "minoring"

    @staticmethod
    def from_str(key):
        if key in ("interpolation", "Interpolation"):
            return AUCSummationMethod.INTERPOLATION
        elif key in ("majoring", "Majoring"):
            return AUCSummationMethod.MAJORING
        elif key in ("minoring", "Minoring"):
            return AUCSummationMethod.MINORING
        else:
            raise ValueError(
                f'Invalid AUC summation method value: "{key}". '
                'Expected values are ["interpolation", "majoring", "minoring"]'
            )


def _update_confusion_matrix_variables_optimized(
    variables_to_update,
    y_true,
    y_pred,
    thresholds,
    multi_label=False,
    sample_weights=None,
    label_weights=None,
    thresholds_with_epsilon=False,
):
    """Update confusion matrix variables with memory efficient alternative.

    Note that the thresholds need to be evenly distributed within the list, eg,

View on GitHub (pinned to 7a34a03db6)