我正在使用以下参数训练LightGBM模型:
early_stopping = 15000
param_grid = {'boosting_type': ['gbdt', 'dart', 'goss'],
'num_leaves': np.round(np.random.uniform(20,150, 30)).astype(int),
'learning_rate': loguniform(np.log(0.01), np.log(0.5), 10),
'subsample_for_bin': np.round(np.random.uniform(20000, 300000, 20000)).astype(int),
'min_child_samples': np.round(np.random.uniform(20, 500, 5)).astype(int),
'reg_alpha': np.random.uniform(0.0, 1.0, 10),
'reg_lambda': np.random.uniform(0.0, 1.0, 10),
'colsample_bytree': np.random.uniform(0.6, 1.0, 10),
'is_unbalance': [True, False],
'nthread': [20],
'n_monte_carlo': [1],
'num_round': [200000],
'count_n': [0],
'mc_test': [True, False],
'objective': ['softmax'],
'cv_n': [10],
'num_classes': [3],
'subsample': [0.9, 0.8, 0.6, 0.75, 0.4],
'gamma': [0, 1, 2, 4, 8, 16],
'max_depth': [4, 5, 6, 7, 8, 9, 11, 13, 15, 17, 20, 23, 26],
'eval_metric': ['mlogloss', 'merror'],
'eta': [0.03, 0.1, 0.01, 0.5, 0.05]
}
这将花费大量时间,并且我想将每次迭代中使用的得分和参数保存到数据帧中,以便以后如果我必须中断训练时能够以某种方式将此信息传递给模型阶段,以免它再次从头开始,并继续到之前停止的地方。
我正在使用lgbm.train()
功能以及内置的交叉验证方法。
我该如何实现?如有需要,随时询问更多代码示例
预先感谢