This page

Citing

Please consider citing the scikit-learn.

9.8.1.2. sklearn.metrics.roc_curve

sklearn.metrics.roc_curve(y_true, y_score)

compute Receiver operating characteristic (ROC)

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

Parameters :

y_true : array, shape = [n_samples]

true binary labels

y_score : array, shape = [n_samples]

target scores, can either be probability estimates of the positive class, confidence values, or binary decisions.

Returns :

fpr : array, shape = [>2]

False Positive Rates

tpr : array, shape = [>2]

True Positive Rates

thresholds : array, shape = [>2]

Thresholds on proba_ used to compute fpr and tpr

References

http://en.wikipedia.org/wiki/Receiver_operating_characteristic

Examples

>>> import numpy as np
>>> from sklearn import metrics
>>> y = np.array([1, 1, 2, 2])
>>> scores = np.array([0.1, 0.4, 0.35, 0.8])
>>> fpr, tpr, thresholds = metrics.roc_curve(y, scores)
>>> fpr
array([ 0. ,  0.5,  0.5,  1. ])