xgboost icon indicating copy to clipboard operation
xgboost copied to clipboard

Setting verbose_eval to False causes DivisionByZero

Open sakvaua opened this issue 10 years ago • 1 comments

I just updated my XGBOOST (Win 7 64bit, python 2.7.10 64bit) and got division by zero exception.

---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-45-1d664724d7eb> in <module>()
     25     for test_cell,test_y,train_cell,train_y,val_cell,val_y in cells:
     26         t1 = datetime.now()
---> 27         s,it=XGBCV(train_cell,train_y,test_cell,test_y, val_cell,val_y,param=params)
     28         t2 = datetime.now()
     29         delta = t2 - t1

<ipython-input-38-fb1a458e513e> in XGBCV(train, y_train, test, y_test, val, y_val, param, n_iter)
     31         bst = xgb.train(param, xg_train, 1000, evallist,
     32                 early_stopping_rounds=10,
---> 33                 feval=mapk_prob,maximize=True, verbose_eval=param['verbose_eval'])
     34 
     35 
c:\winpython64\python-2.7.10.amd64\lib\site-packages\xgboost-0.4-py2.7.egg\xgboost\training.pyc in train(params, dtrain, num_boost_round, evals, obj, feval, maximize, early_stopping_rounds, evals_result, verbose_eval, learning_rates, xgb_model, callbacks)
    203                            evals=evals,
    204                            obj=obj, feval=feval,
--> 205                            xgb_model=xgb_model, callbacks=callbacks)
    206 
    207 

c:\winpython64\python-2.7.10.amd64\lib\site-packages\xgboost-0.4-py2.7.egg\xgboost\training.pyc in _train_internal(params, dtrain, num_boost_round, evals, obj, feval, xgb_model, callbacks)
     99                                end_iteration=num_boost_round,
    100                                rank=rank,
--> 101                                evaluation_result_list=evaluation_result_list))
    102         except EarlyStopException:
    103             break

c:\winpython64\python-2.7.10.amd64\lib\site-packages\xgboost-0.4-py2.7.egg\xgboost\callback.pyc in callback(env)
     42             return
     43         i = env.iteration
---> 44         if (i % period == 0 or i + 1 == env.begin_iteration):
     45             msg = '\t'.join([_fmt_metric(x, show_stdv) for x in env.evaluation_result_list])
     46             rabit.tracker_print('[%d]\t%s\n' % (i, msg))

ZeroDivisionError: integer division or modulo by zero

sakvaua avatar Jun 05 '16 15:06 sakvaua

Checked on a different machine - same thing. The error is in python callback module. I did a rough patch (checking if period is 0) to fix it but that's surely not a correct way to address the issue.

sakvaua avatar Jun 06 '16 15:06 sakvaua