学习笔记 Day 51(xgb参数应用)

默认参数下:

defull = xgboost.DMatrix(data.data,data.target)

param = {'silent':True,'obj':'reg:linear','subsample':1,
         'max_depth':6,'eta':0.3,'gamma':0,'lambda':1,
         'alpha':0,'colsample_bytree':1,'colsample_bylevel':1,
         'colsample_bynode':1,'nfold':5}

num_round = 200

time_start = time()
estimator = xgboost.cv(param,defull,num_round)

print(datetime.datetime.fromtimestamp(time()-time_start).strftime("%M:%S:%f"))

# 学习曲线
fig,ax = plt.subplots(1,figsize=(20,8))

ax.grid()
ax.plot(range(1,201),estimator.iloc[:,0],label='train')
ax.plot(range(1,201),estimator.iloc[:,2],label='test')

ax.set_ylim(top=5)
ax.legend()
plt.show()

 模型存在明显过拟合的现象。

后续调参会发现,max——depth和eta对模型的过拟合现象会有最明显的改善,而使用'colsample_bylevel':0.4时,效果虽然只有轻微的改善,但降低了运行时间,这里对'colsample_bylevel'也进行调整

模型保存和读取:

 其它参数:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值