title: How to use scipy optimize with your own function?
body: <p>I have scores from 3 different metrics that I combine into one weight, and I want to use scipy's optimize to determine the optimal coefficients for the weights when combining (rather than treating them all equally and taking the average, which is what I was doing before). The CV function shown in the code below deals with implementing cross validation and computing the predictions for the reactions (where a reaction is only "like" or "dislike"). </p>
  
  <pre><code>weight = A*(metric1) + B*(metric2) + C*(metric3)
  prediction = CV(post, reaction, weight)
  </code></pre>
  
  <p>I want to maximize my <code>accuracy</code>, or minimize <code>1 - accuracy</code>, where <code>accuracy = accuracy_score(reaction, prediction)</code>. I looked at the documentation for scipy's optimize/minimize and while I understand the general idea, I am not sure how to translate my ideas into actual code. For example, one area of confusion is that I want to minimize '1-accuracy', but accuracy is determined by the previous part that deals with predictions. Any help would be greatly appreciated and as always, code would be super helpful :)</p>