def AreaUnderCurve(x, y):
<EOL>if x.shape[<NUM_LIT:0>] != y.shape[<NUM_LIT:0>]:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (x.shape, y.shape))<EOL><DEDENT>if x.shape[<NUM_LIT:0>] < <NUM_LIT:2>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % x.shape)<EOL><DEDENT>order = np.argsort(x)<EOL>x = x[order]<EOL>y = y[order]<EOL>h = np.diff(x)<EOL>area = np.sum(h * (y[<NUM_LIT:1>:] + y[:-<NUM_LIT:1>])) / <NUM_LIT><EOL>return area<EOL>
Compute Area Under the Curve (AUC) using the trapezoidal rule

    Parameters
    ----------
    x : array, shape = [n]
        x coordinates

    y : array, shape = [n]
        y coordinates

    Returns
    -------
    auc : float

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn import metrics
    >>> y = np.array([1, 1, 2, 2])
    >>> pred = np.array([0.1, 0.4, 0.35, 0.8])
    >>> fpr, tpr, thresholds = metrics.roc_curve(y, pred)
    >>> metrics.auc(fpr, tpr)
    0.75