下面是我训练的xgboost模型的代码和结果。我想知道训练每次迭代需要多长时间,以便可以更好地估算以后可以训练多少回合。有没有办法打印出每轮训练后模型训练所需的时间,例如结果在同一行? 谢谢!
import xgboost as xgb
dtrain = xgb.DMatrix(X_train, label=y_train)
# parameters
param = {'max_depth': 2, 'eta': 1, 'objective': 'binary:logistic'}
param['nthread'] = 4
param['eval_metric'] = 'auc'
evallist = [(dtest, 'eval'), (dtrain, 'train')]
num_round = 10
bst = xgb.train(param, dtrain, num_round, evallist)
结果:
[0] eval-auc:0.618416 train-auc:0.621827
[1] eval-auc:0.733406 train-auc:0.734433
...
[8] eval-auc:0.854423 train-auc:0.856366
[9] eval-auc:0.855932 train-auc:0.857541