from sklearn.metrics import mean_squared_error as MSE
MSE(Ytest, y_pre, squared=False)# RMSE'''
0.9434823962603885
'''
# 交叉验证# seed控制树的生长和分支随机性
param ={'seed':1107,'metric':'rmse','force_col_wise':True}'''
stratified 默认Ture
https://blog.csdn.net/qq_45249685/article/details/128690834
针对分类算法,保证每折数据的标签类别比例与全数据一致
lgb.cv()默认使用stratified进行交叉验证,对回归算法无意义。
seed
控制交叉验证随机性
'''
result = lgb.cv(param, traindata, nfold=5, num_boost_round=10, seed=1107, stratified=False)'''
[LightGBM] [Info] Total Bins 835
[LightGBM] [Info] Number of data points in the train set: 1148, number of used features: 53
[LightGBM] [Info] Total Bins 835
[LightGBM] [Info] Number of data points in the train set: 1148, number of used features: 53
[LightGBM] [Info] Total Bins 835
[LightGBM] [Info] Number of data points in the train set: 1148, number of used features: 53
[LightGBM] [Info] Total Bins 835
[LightGBM] [Info] Number of data points in the train set: 1148, number of used features: 53
[LightGBM] [Info] Total Bins 835
[LightGBM] [Info] Number of data points in the train set: 1148, number of used features: 53
[LightGBM] [Info] Start training from score 4.452091
[LightGBM] [Info] Start training from score 4.554007
[LightGBM] [Info] Start training from score 4.521777
[LightGBM] [Info] Start training from score 4.527003
[LightGBM] [Info] Start training from score 4.499129
'''