title: How can i correctly set a decaying learning rate callback passing it a custom function in xgboost?
body: <p>I have this function to set up a descending learning rate:</p>
  
  <pre><code>def learning_rate_005_decay_power_099(current_iter):
      base_learning_rate = 0.05
      lr = base_learning_rate  * np.power(.99, current_iter)
      return lr if lr &gt; 1e-3 else 1e-3
  </code></pre>
  
  <p>Now i want to pass it to the <code>callback</code> parameter in the <code>train</code> API of <code>xgboost</code>. I'm trying this:</p>
  
  <pre><code>watchlist = [(xg_train, 'train'), (xg_test, 'test')]
  
  num_round = params['num_round']
  xgclassifier = xgb.train(params, xg_train, num_round, watchlist, early_stopping_rounds=early_stopping, callbacks = [xgb.callback.reset_learning_rate(learning_rate_005_decay_power_099)]);
  </code></pre>
  
  <p>But i'm getting this error:</p>
  
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-142-398cd3e1ab95&gt; in &lt;module&gt;
       82 
       83             num_round = params['num_round']
  ---&gt; 84             xgclassifier = xgb.train(params, xg_train, num_round, watchlist, early_stopping_rounds=early_stopping, callbacks = [xgb.callback.reset_learning_rate(learning_rate_005_decay_power_099)]);
       85             xgb_rounds.append(xgclassifier.best_iteration)
       86 
  
  ~/.local/lib/python3.6/site-packages/xgboost/training.py in train(params, dtrain, num_boost_round, evals, obj, feval, maximize, early_stopping_rounds, evals_result, verbose_eval, xgb_model, callbacks, learning_rates)
      214                            evals=evals,
      215                            obj=obj, feval=feval,
  --&gt; 216                            xgb_model=xgb_model, callbacks=callbacks)
      217 
      218 
  
  ~/.local/lib/python3.6/site-packages/xgboost/training.py in _train_internal(params, dtrain, num_boost_round, evals, obj, feval, xgb_model, callbacks)
       68                            end_iteration=num_boost_round,
       69                            rank=rank,
  ---&gt; 70                            evaluation_result_list=None))
       71         # Distributed code: need to resume to this point.
       72         # Skip the first update if it is a recovery step.
  
  ~/.local/lib/python3.6/site-packages/xgboost/callback.py in callback(env)
      137         if context == 'train':
      138             bst, i, n = env.model, env.iteration, env.end_iteration
  --&gt; 139             bst.set_param('learning_rate', get_learning_rate(i, n, learning_rates))
      140         elif context == 'cv':
      141             i, n = env.iteration, env.end_iteration
  
  ~/.local/lib/python3.6/site-packages/xgboost/callback.py in get_learning_rate(i, n, learning_rates)
      128             new_learning_rate = learning_rates[i]
      129         else:
  --&gt; 130             new_learning_rate = learning_rates(i, n)
      131         return new_learning_rate
      132 
  
  TypeError: learning_rate_005_decay_power_099() takes 1 positional argument but 2 were given
  </code></pre>
  
  <p>If i try this with <code>lightgbm</code> using exactly the same working routine, it works nice:</p>
  
  <pre><code>xg_train = lgb.Dataset(X_train, label=y_train, silent = True)
              xg_test = lgb.Dataset(X_test, label=y_test, silent = True)
  
              watchlist = [xg_train, xg_test]
              names = ['train', 'test']
  
              xgclassifier = lgb.train(params, xg_train, num_round, valid_sets = watchlist, valid_names = names, early_stopping_rounds= early_stopping,
                                       callbacks=[lgb.reset_parameter(learning_rate=learning_rate_005_decay_power_099)]);
  </code></pre>
  
  <p>How can this operation be set correctly please? And also, what makes different the 2 calls in <code>xgboost</code> and <code>lightgbm</code>?</p>
  
  <p>Thank you very much in advance</p>