title: Getting the maximum accuracy for a binary probabilistic classifier in scikit-learn
body: <p>Is there any built-in function to get the maximum accuracy for a binary probabilistic classifier in scikit-learn?</p>
  
  <p>E.g. to get the maximum F1-score I do:</p>
  
  <pre><code># AUCPR
  precision, recall, thresholds = sklearn.metrics.precision_recall_curve(y_true, y_score)    
  auprc  = sklearn.metrics.auc(recall, precision)
  max_f1 = 0
  for r, p, t in zip(recall, precision, thresholds):
      if p + r == 0: continue
      if (2*p*r)/(p + r) &gt; max_f1:
          max_f1 = (2*p*r)/(p + r) 
          max_f1_threshold = t
  </code></pre>
  
  <p>I could compute the maximum accuracy in a similar fashion:</p>
  
  <pre><code>accuracies = []
  thresholds = np.arange(0,1,0.1)
  for threshold in thresholds:
      y_pred = np.greater(y_score, threshold).astype(int)
      accuracy = sklearn.metrics.accuracy_score(y_true, y_pred)
      accuracies.append(accuracy)
  
  accuracies = np.array(accuracies)
  max_accuracy = accuracies.max() 
  max_accuracy_threshold =  thresholds[accuracies.argmax()]
  </code></pre>
  
  <p>but I wonder whether there is any built-in function.</p>