precision_recall_curve#
- cuml.metrics.precision_recall_curve(y_true, probs_pred) Tuple[CumlArray, CumlArray, CumlArray][source]#
Compute precision-recall pairs for different probability thresholds
Note
this implementation is restricted to the binary classification task. The precision is the ratio
tp / (tp + fp)wheretpis the number of true positives andfpthe number of false positives. The precision is intuitively the ability of the classifier not to label as positive a sample that is negative.The recall is the ratio
tp / (tp + fn)wheretpis the number of true positives andfnthe number of false negatives. The recall is intuitively the ability of the classifier to find all the positive samples. The last precision and recall values are 1. and 0. respectively and do not have a corresponding threshold. This ensures that the graph starts on the y axis.Read more in the scikit-learn’s User Guide.
- Parameters:
- y_truearray, shape = [n_samples]
True binary labels, {0, 1}.
- probas_predarray, shape = [n_samples]
Estimated probabilities or decision function.
- Returns:
- precisionarray, shape = [n_thresholds + 1]
Precision values such that element i is the precision of predictions with score >= thresholds[i] and the last element is 1.
- recallarray, shape = [n_thresholds + 1]
Decreasing recall values such that element i is the recall of predictions with score >= thresholds[i] and the last element is 0.
- thresholdsarray, shape = [n_thresholds <= len(np.unique(probas_pred))]
Increasing thresholds on the decision function used to compute precision and recall.
Examples
>>> import cupy as cp >>> from cuml.metrics import precision_recall_curve >>> y_true = cp.array([0, 0, 1, 1]) >>> y_scores = cp.array([0.1, 0.4, 0.35, 0.8]) >>> precision, recall, thresholds = precision_recall_curve( ... y_true, y_scores) >>> print(precision) [0.666... 0.5 1. 1. ] >>> print(recall) [1. 0.5 0.5 0. ] >>> print(thresholds) [0.35 0.4 0.8 ]