title: Why doesn't GridSearchCV give C with highest AUC when scoring roc_auc in logistic regression
body: <p>I'm new to this so apologies if this is obvious.</p>
  
  <pre><code>lr = LogisticRegression(penalty = 'l1')
  parameters = {'C': [0.001, 0.01, 0.1, 1, 10, 100, 1000]}
  clf = GridSearchCV(lr, parameters, scoring='roc_auc', cv = 5)
  clf.fit(X, Y)
  print clf.score(X, Y)
  tn, fp, fn, tp = metrics.confusion_matrix(Y, clf.predict(X)).ravel()
  print tn, fp, fn, tp
  </code></pre>
  
  <p>I want to run a Logistic Regression - I'm using an L1 penalty because I want to reduce the number of features I use. I'm using GridSearchCV to find the best C value for the Logistic Regression</p>
  
  <p>I run this and get C = 0.001, AUC = 0.59, Confusion matrix: 46, 0, 35, 0. Only 1 feature has a non-zero coefficient.
  I go back to my code and remove the option of C = 0.001 from my parameter list and run it again. 
  Now I get C = 1, AUC = 0.95, Confusion matrix: 42, 4, 6, 29. Many, but not all, features have a non-zero coefficient.</p>
  
  <p>I thought that since I have scoring as 'roc_auc' shouldn't the model be created with a better AUC?</p>
  
  <p>Thinking this may be to do with my l1 penalty I switched it to l2. But this gave C = 0.001, AUC = 0.80, CM = 42,4,16,19 and again when I removed C = 0.001 as an option it gave C = 0.01, AUC = 0.88, CM = 41,5,13,22.</p>
  
  <p>There is less of an issue with the l2 penalty but it seems to be a pretty big difference in l1. Is it a penalty thing?</p>
  
  <p>From some of my readings I know ElasticNet is supposed to combine some l1 and l2 - is that where I should be looking?</p>
  
  <p>Also, not completely relevant but while I'm posting - I haven't done any data normalization for this. That is normal for Logistic Regression?</p>