title: f1_score metric in lightgbm
body: <p>I want to train a lgb model with custom metric : <code>f1_score</code> with <code>weighted</code> average.</p>
  
  <p>I went through the advanced examples of lightgbm over <a href="https://github.com/Microsoft/LightGBM/blob/master/examples/python-guide/advanced_example.py" rel="noreferrer">here</a> and found the implimentation of custom binary error function. I implemented as similiar functon to return f1_score as shown below.</p>
  
  <pre><code>def f1_metric(preds, train_data):
  
      labels = train_data.get_label()
  
      return 'f1', f1_score(labels, preds, average='weighted'), True
  </code></pre>
  
  <p>I tried to train the model by passing <code>feval</code> parameter as <code>f1_metric</code> as shown below. </p>
  
  <pre><code>evals_results = {}
  
  bst = lgb.train(params, 
                       dtrain, 
                       valid_sets= [dvalid], 
                       valid_names=['valid'], 
                       evals_result=evals_results, 
                       num_boost_round=num_boost_round,
                       early_stopping_rounds=early_stopping_rounds,
                       verbose_eval=25, 
                       feval=f1_metric)
  </code></pre>
  
  <p>Then I am getting <code>ValueError: Found input variables with inconsistent numbers of samples:</code></p>
  
  <p>The training set is being passed to the function rather than the validation set.</p>
  
  <p>How can I configure such that the validation set is passed and f1_score is returned.?</p>