python实现lightgbm以及重要参数解析

更新时间:2023-05-20 09:04:02 阅读: 评论:0

打电话的英文单词python实现lightgbm以及重要参数解析lightgbm参数解析
max_depth : 树的深度萌猫snoopy
num_leaves : 树的最⼤叶⼦节点数
objective : ⽬标函数
min_data_in_leaf : ⼀个叶⼦上最⼩数据量
learning_rate : 学习率
feature_fraction : 随机抽取特征的⽐例
bagging_fraction : 在不进⾏重采样的情况下随机选择部分数据
bagging_freq : bagging的频率,k意味着每k次迭代执⾏bagging
中学英语metric : 评价指标
is_unbalance : 数据是否平衡
import lightgbm as lg
def print_feature_importance_lgb(gbm):conversational
print(80*'*')
print(31*'*'+'Feature Importance'+31*'*')
print(80*'.')
print("\n".join((".%50s => %9.5f"% x)for x in sorted(
日语等级zip(gbm.feature_name(), gbm.feature_importance("gain")),
key=lambda x: x[1],
wholefoods
rever=True)))
print(80*'.')
def fit_lgb(X_tr,y_tr,X_va,y_va,cates_cols):
围裙英文
params ={
'max_depth':8,
'num_leaves':128,
'objective':'binary',
'min_data_in_leaf':20,
'learning_rate':0.01,
'feature_fraction':0.9,二建考试科目
'bagging_fraction':0.8,
amstress
'subsample':0.85,
'bagging_freq':1,
'random_state':2019,
'metric':["binary_logloss"],
'num_threads':16,
'is_unbalance':True
}
weightMAX_ROUNDS =10000
dtr = lg.Datat(X_tr, label=y_tr, categorical_feature=cates_cols)
dva = lg.Datat(X_va, label=y_va, categorical_feature=cates_cols, reference=dtr)
cls = lg.train(
params,
dtr,
num_boost_round=MAX_ROUNDS,
valid_ts=(dva, dtr),
valid_names=['valid','train'],
early_stopping_rounds=125,
verbo_eval=50)
print_feature_importance_lgb(cls)
lg.plot_importance(cls, importance_type='gain', figsize=(11,12), max_num_features=50, grid=Fal) return cls
gbm = fit_lgb(X_tr, y_tr, X_va, y_va, nominal_cate_cols)

本文发布于:2023-05-20 09:04:02,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/115607.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:意味着   参数   数据   情况   部分   选择   解析
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图