title: How to get F1 Score and Accuracy for every model tried with GridSearchCV?
body: <p>I am trying to get the <code>F1 score</code> and <code>accuracy</code> for each model trained with my SVM, so for every set of parameters tried with <code>GridSearchCV</code>. I might have found how to do so for <code>accuracy</code>, but I have no idea how to do this for <code>F1 Score</code>. </p>
  
  <p>For example, I'd like the F1 for kernel <code>linear</code>, and <code>c=1e-3</code>. Then F1 again for <code>linear and C=1e-1</code>, and finally F1 score for <code>linear and C=1</code> and <code>C=10</code>. How?</p>
  
  <p>Here is a bit of my code that is relevant:</p>
  
  <pre><code>parameters = {'kernel':['linear'], 'C':[1e-3, 1e-1, 1, 10]}
  
  svc = svm.SVC(cache_size=2048)
  cv = StratifiedShuffleSplit(n_splits=5, test_size=0.2, random_state=42)
  clf = GridSearchCV(svc, parameters, cv=cv, n_jobs=8)
  grid_result = clf.fit(X_train, y_train)
  grid_result.cv_results_
  my_dict = defaultdict(partial(np.ndarray, 0))
  my_dict['params'] = grid_result.cv_results_['params']
  my_dict['mean_valid_score'] = grid_result.cv_results_['mean_test_score'] # accuracy for valid dataset
  my_dict['mean_train_score'] = grid_result.cv_results_['mean_train_score'] # accuracy for train
  </code></pre>
  
  <p>I read the <a href="http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html#sklearn.model_selection.GridSearchCV" rel="nofollow noreferrer">GridSearchCV</a> documentation, but I can't find anything that does what I need. </p>
  
  <p>I found <code>cv_results_</code>, which gives a couple of information, like <code>mean_valid_score</code> and <code>mean_train_score</code> seems to be giving me the <code>accuracy</code> score for every model tried if I understand correctly. But F1 isn't there.</p>
  
  <p>There is also <a href="http://scikit-learn.org/stable/modules/model_evaluation.html#scoring-parameter" rel="nofollow noreferrer">scoring</a> that seems interesting, maybe it does what I want? But I can't understand how to use it for my problem, and how to actually get the scores for each model tried.  </p>
  
  <p>I also found on some forums <code>grid_scores_</code>, like this <a href="https://stackoverflow.com/questions/36461289/how-to-get-accuracy-and-f1-score-from-each-fold-in-gridsearchcv">SO thread</a> but it seems to be <a href="https://www.quora.com/How-do-I-find-out-the-model-produced-by-a-GridSearchCV-for-any-fold-produced-by-cross_val_score/answer/Manoj-Kumar-23" rel="nofollow noreferrer">deprecated</a> now, and I can't find anything about this in the documentation as of now? How do we use it?</p>
  
  <p>I want to do something like <a href="https://blancas.io/sklearn-evaluation/user_guide/grid_search.html" rel="nofollow noreferrer">this</a>, but for different measures: accuracy and f1! </p>