model = lightgbm.LGBMClassifier()
hyperparameter_dictionary = {'boosting_type': 'goss', 'num_leaves': 25, 'n_estimators': 184, ...}
如何通过字典分配模型的超参数,以便可以使用此类超参数尝试模型的行为?
谢谢!
最佳答案
将hyperparam字典传递给模型构造函数,在dict上添加**
以像warg param一样传递每个dict项,因为lgbm希望每个https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.LGBMClassifier.html#lightgbm.LGBMClassifier传递它:
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,...)
关于python - 如何手动将超参数分配给LGBM,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59635480/