def precision_recall_curve(y_true, probas_pred, pos_label=None, sample_weight=None):
 (fps, tps, thresholds) = _binary_clf_curve(y_true, probas_pred, pos_label=pos_label, sample_weight=sample_weight)
 precision = (tps / (tps + fps))
 recall = (tps / tps[(-1)])
 last_ind = tps.searchsorted(tps[(-1)])
 sl = slice(last_ind, None, (-1))
 return (np.r_[(precision[sl], 1)], np.r_[(recall[sl], 0)], thresholds[sl])

def precision_recall_curve ( y_true , probas_pred , pos_label = None , sample_weight = None ) : ( fps , tps , thresholds ) = _binary_clf_curve ( y_true , probas_pred , pos_label = pos_label , sample_weight = sample_weight ) precision = ( tps / ( tps + fps ) ) recall = ( tps / tps [ ( - 1 ) ] ) last_ind = tps . searchsorted ( tps [ ( - 1 ) ] ) sl = slice ( last_ind , None , ( - 1 ) ) return ( np . r_ [ ( precision [ sl ] , 1 ) ] , np . r_ [ ( recall [ sl ] , 0 ) ] , thresholds [ sl ] )
compute precision-recall pairs for different probability thresholds note: this implementation is restricted to the binary classification task .