python - How to manually assign hyperparameter to LGBM
问题描述
model = lightgbm.LGBMClassifier()
hyperparameter_dictionary = {'boosting_type': 'goss', 'num_leaves': 25, 'n_estimators': 184, ...}
How do I assign the model's hyperparameters by the dictionary, so that I can try out the model's behavior with such hyperparameters?
Thanks!
解决方案
将超参数字典传递给模型构造函数,添加**
到 dict 以传递每个 dict 项,如 lgbm 期望的 kwarg 参数https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.LGBMClassifier.html#lightgbm .LGBM分类器:
hyperparameter_dictionary = {'boosting_type': 'goss', 'num_leaves': 25, 'n_estimators': 184}
model = lightgbm.LGBMClassifier(**hyperparameter_dictionary)
测试:
print(model)
LGBMClassifier(boosting_type='goss', ... n_estimators=184, n_jobs=-1, num_leaves=25,...)
推荐阅读
- sql - 不显示日期期间
- ios - 返回上一个视图后,SwiftUI NavigationLink 突出显示保持突出显示
- django - Django 两种相同的信号类型
- android - 颤振构建apk失败-无法确定任务':app:processDebugResources'的依赖关系
- bootstrap-4 - 所有列 Boostrap4 的宽度相同
- python - 根据从 API Endpoint 推断的字段类型自动创建 SnowFlake 表的方法?(Python)
- mysql - 是否可以在 MySQL 中动态创建表?
- while-loop - 与while循环混淆
- html - Xpath:如何选择以下兄弟姐妹直到相似的当前节点
- azure - 请求通过多个 Azure 网络组件进行跟踪?