一、安装
xgboost:
安装包路径:https://www.lfd.uci.edu/~gohlke/pythonlibs/#xgboost
找到合适的包,使用pip安装
如 pip install xgboost-0.81-cp27-cp27m-win_amd64.whl
lightgbm:
可直接通过 pip install lightgbm 安装
二、介绍
xgboost 与 lightgbm 均有原生模型及 仿sklearn 接口,两者均可以达到建模的目的,这里就不详细介绍。两者调用方法及参数设置都及其类似,仅在少数参数上略有不同。使用是只要会用其一,便可举一反三。至于原理上的东西,这里就不做赘述,可参考:XGBoost、LightGBM的详细对比介绍
三、调参
以下以xgboost为例,lightgbm除个别参数名字不同外,大体与之类似
步骤:
0、设置初始参数
给出一堆初始参数
best_params = {
'learning_rate': 0.1,
'n_estimators': 1000,
'max_depth': 5,
'min_child_weight': 1,
'gamma': 0,
'subsample': 0.8,
'colsample_bytree': 0.8,
'nthread': 4,