MCPcopy Index your code
hub / github.com/clips/pattern / roc

Function roc

pattern/metrics.py:190–198  ·  view source on GitHub ↗

Returns the ROC curve as an iterator of (x, y)-points, for the given list of (TP, TN, FP, FN)-tuples. The x-axis represents FPR = the false positive rate (1 - specificity). The y-axis represents TPR = the true positive rate.

(tests=[])

Source from the content-addressed store, hash-verified

188# See: Tom Fawcett (2005), An Introduction to ROC analysis.
189
190def roc(tests=[]):
191 """ Returns the ROC curve as an iterator of (x, y)-points,
192 for the given list of (TP, TN, FP, FN)-tuples.
193 The x-axis represents FPR = the false positive rate (1 - specificity).
194 The y-axis represents TPR = the true positive rate.
195 """
196 x = FPR = lambda TP, TN, FP, FN: float(FP) / ((FP + TN) or 1)
197 y = TPR = lambda TP, TN, FP, FN: float(TP) / ((TP + FN) or 1)
198 return sorted([(0.0, 0.0), (1.0, 1.0)] + [(x(*m), y(*m)) for m in tests])
199
200def auc(curve=[]):
201 """ Returns the area under the curve for the given list of (x, y)-points.

Callers

nothing calls this directly

Calls 1

yFunction · 0.85

Tested by

no test coverage detected