Build a receiver operating characteristic curve from binary labels and prediction scores. Sort samples by descending score and group tied scores into one threshold. At each threshold compute:
TPR=PTP FPR=NFPHere, P and N are the total positive and negative counts. Begin with fpr=0, tpr=0, and an infinite threshold, then append one point per unique score. Return fpr, tpr, and thresholds as NumPy arrays in a dictionary.
Input: y_true = [0, 1], y_score = [0.1, 0.9]
Output: {"fpr": [0.0, 0.0, 1.0], "tpr": [0.0, 1.0, 1.0], "thresholds": ["inf", 0.9, 0.1]}
Explanation: The positive sample crosses first, followed by the negative sample at the lower threshold.
Input: y_true = [1, 0, 1, 0], y_score = [0.9, 0.7, 0.4, 0.2]
Output: {"fpr": [0.0, 0.0, 0.5, 0.5, 1.0], "tpr": [0.0, 0.5, 0.5, 1.0, 1.0], "thresholds": ["inf", 0.9, 0.7, 0.4, 0.2]}
Use cumulative positive and negative counts after a stable descending sort.
Select the final index of each tied-score group with np.diff(sorted_scores).
Sign in to take notes on this problem
Accepts: array
Accepts: array
Build a receiver operating characteristic curve from binary labels and prediction scores. Sort samples by descending score and group tied scores into one threshold. At each threshold compute:
TPR=PTP FPR=NFPHere, P and N are the total positive and negative counts. Begin with fpr=0, tpr=0, and an infinite threshold, then append one point per unique score. Return fpr, tpr, and thresholds as NumPy arrays in a dictionary.
Input: y_true = [0, 1], y_score = [0.1, 0.9]
Output: {"fpr": [0.0, 0.0, 1.0], "tpr": [0.0, 1.0, 1.0], "thresholds": ["inf", 0.9, 0.1]}
Explanation: The positive sample crosses first, followed by the negative sample at the lower threshold.
Input: y_true = [1, 0, 1, 0], y_score = [0.9, 0.7, 0.4, 0.2]
Output: {"fpr": [0.0, 0.0, 0.5, 0.5, 1.0], "tpr": [0.0, 0.5, 0.5, 1.0, 1.0], "thresholds": ["inf", 0.9, 0.7, 0.4, 0.2]}
Use cumulative positive and negative counts after a stable descending sort.
Select the final index of each tied-score group with np.diff(sorted_scores).
Sign in to take notes on this problem
Accepts: array
Accepts: array