title: How to use precision_recall_curve to calculate precision from recall value
body: <p>I try to calculate precision from recall value (e.g. 0.9) using precision-recall curve.  The way I do is to find the index (idx) near minimum value of abs(recall - 0.9), and then find the precision(idx) I can use interpolate from the two sides of minimum values to improve the accuracy.  However, I think there must be a better way. Is there an function to look up or interpolate the prevision from recall or vice verse from prevision-recall curve?   </p>
  
  <p>The below is my code.  I try to get a better way of doing it. </p>
  
  <pre><code>from sklearn.metrics import precision_recall_curve
  y_scores_lr = m.decision_function(X_test)
  precision, recall, thresholds = precision_recall_curve(y_test, y_scores_lr)
  idx = abs(recall - 0.9).argmin()
  prec = precision[idx] # use interpolation to get a better result
  </code></pre>