title: How to use `log_loss` in `GridSearchCV` with multi-class labels in Scikit-Learn (sklearn)?
body: <p>I'm trying to use the <code>log_loss</code> argument in the <code>scoring</code> parameter of <code>GridSearchCV</code> to tune this multi-class (6 classes) classifier. I don't understand how to give it a <code>label</code> parameter.  Even if I gave it <code>sklearn.metrics.log_loss</code>, it would change for each iteration in the cross-validation so I don't understand how to give it the <code>labels</code> parameter? </p>
  
  <p>I'm using <code>Python v3.6</code> and <code>Scikit-Learn v0.18.1</code></p>
  
  <p><strong>How can I use <code>GridSearchCV</code> with <code>log_loss</code> with multi-class model tuning?</strong> </p>
  
  <p>My class representation: </p>
  
  <pre><code>1    31
  2    18
  3    28
  4    19
  5    17
  6    22
  Name: encoding, dtype: int64
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>param_test = {"criterion": ["friedman_mse", "mse", "mae"]}
  gsearch_gbc = GridSearchCV(estimator = GradientBoostingClassifier(n_estimators=10), 
                          param_grid = param_test, scoring="log_loss", n_jobs=1, iid=False, cv=cv_indices)
  gsearch_gbc.fit(df_attr, Se_targets)
  </code></pre>
  
  <p>Here's the tail end of the error and the full one is here <a href="https://pastebin.com/1CshpEBN" rel="noreferrer">https://pastebin.com/1CshpEBN</a>: </p>
  
  <pre><code>ValueError: y_true contains only one label (1). Please provide the true labels explicitly through the labels argument.
  </code></pre>
  
  <p><strong>UPDATE:</strong> 
  Just use this to make the scorer based on based on @Grr</p>
  
  <pre><code>log_loss_build = lambda y: metrics.make_scorer(metrics.log_loss, greater_is_better=False, needs_proba=True, labels=sorted(np.unique(y)))
  </code></pre>