Repository: scikit-learn/scikit-learn
File: sklearn/metrics/_ranking.py (Python)

Code before:
    )
    return _average_binary_score(
        average_precision, y_true, y_score, average, sample_weight=sample_weight
    )


@validate_params(
    {
        "y_true": ["array-like"],
        "y_score": ["array-like"],
        "pos_label": [Real, str, "boolean", None],
        "sample_weight": ["array-like", None],
        "drop_intermediate": ["boolean"],
    },
    prefer_skip_nested_validation=True,
)
def det_curve(
    y_true, y_score, pos_label=None, sample_weight=None, drop_intermediate=False
):
    """Compute Detection Error Tradeoff (DET) for different probability thresholds.

    Note: this implementation is restricted to the :term:`binary` classification task.

    DET curve is used for evaluation of ranking and error tradeoffs of binary
    classification tasks.

    Read more in the :ref:`User Guide <det_curve>`.

    .. versionadded:: 0.24

    .. versionchanged:: 1.7
       An arbitrary threshold at infinity is added to represent a classifier
       that always predicts the negative class, i.e. `fpr=0` and `fnr=1`, unless
       `fpr=0` is already reached at a finite threshold.

    Parameters
    ----------
    y_true : ndarray of shape (n_samples,)
        True binary labels. If labels are not either {-1, 1} or {0, 1}, then
        pos_label should be explicitly given.

    y_score : ndarray of shape of (n_samples,)
        Target scores, can either be probability estimates of the positive
        class, confidence values, or non-thresholded measure of decisions
        (as returned by "decision_function" on some classifiers).
        For :term:`decision_function` scores, values greater than or equal to
        zero should indicate the positive class.

    pos_label : int, float, bool or str, default=None
        The label of the positive class.
        When ``pos_label=None``, if `y_true` is in {-1, 1} or {0, 1},

Review comment (suggestion):
The note box makes this entry a bit busy:

<img width="1348" height="866" alt="Image" src="https://github.com/user-attachments/assets/7f0361b5-c509-4e90-b0c6-fc12e73dcb9f" />

I've removed the box, making it just text, similar to what is in the `precision_recall_curve` and `roc_curve` API entries.

Code after:
    )
    return _average_binary_score(
        average_precision, y_true, y_score, average, sample_weight=sample_weight
    )


@validate_params(
    {
        "y_true": ["array-like"],
        "y_score": ["array-like"],
        "pos_label": [Real, str, "boolean", None],
        "sample_weight": ["array-like", None],
        "drop_intermediate": ["boolean"],
    },
    prefer_skip_nested_validation=True,
)
def det_curve(
    y_true, y_score, pos_label=None, sample_weight=None, drop_intermediate=False
):
    """Compute Detection Error Tradeoff (DET) for different probability thresholds.

    Note: Support beyond :term:`binary` classification tasks, via one-vs-rest or
    one-vs-one, is not implemented.

    The DET curve is used for evaluation of ranking and error tradeoffs in binary
    classification tasks.

    Read more in the :ref:`User Guide <det_curve>`.

    .. versionadded:: 0.24

    .. versionchanged:: 1.7
       An arbitrary threshold at infinity is added to represent a classifier
       that always predicts the negative class, i.e. `fpr=0` and `fnr=1`, unless
       `fpr=0` is already reached at a finite threshold.

    Parameters
    ----------
    y_true : ndarray of shape (n_samples,)
        True binary labels. If labels are not either {-1, 1} or {0, 1}, then
        pos_label should be explicitly given.

    y_score : ndarray of shape of (n_samples,)
        Target scores, can either be probability estimates of the positive
        class, confidence values, or non-thresholded measure of decisions
        (as returned by "decision_function" on some classifiers).
        For :term:`decision_function` scores, values greater than or equal to
        zero should indicate the positive class.

    pos_label : int, float, bool or str, default=None
        The label of the positive class.