'Returns the area under the ROC-curve.'

def auc(self, k=10):

    roc = [(0.0, 0.0), (1.0, 1.0)]
    for (type, TP, TN, FP, FN) in self.split():
        x = FPR = (float(FP) / ((FP + TN) or 1))
        y = TPR = (float(TP) / ((TP + FN) or 1))
        roc.append((x, y))
    roc = sorted(roc)
    return sum((((0.5 * (x1 - x0)) * (y1 + y0)) for ((x0, y0), (x1, y1)) in sorted(zip(roc, roc[1:]))))
