接上一篇:
<LightGBM预测饭店流量1: 数据处理>
LIghtGBM建模
- model_selection.KFold()
K折交叉验证, 将训练/测试数据集划分n_splits个互斥子集,每次用其中一个子集当作验证集,剩下的n_splits-1个作为训练集,进行n_splits次训练和测试,得到n_splits个结果
import numpy as np
import pandas as pd
import lightgbm as lgbm
from sklearn import metrics
from sklearn import model_selection
np.random.seed(42)
model = lgbm.LGBMRegressor(objective='regression', max_depth=5, num_leaves=25, learning_rate=0.007,
n_estimators=1000, min_child_samples=80, subsample=0.8, colsample_bytree=1,
reg_alpha=0, reg_lambda<