如何打印拟合 XGBoost 模型的超参数?
如果我在数据上拟合 XGBoost 模型并且未设置任何参数(所有参数均为默认值),那么如何打印这些设置?
xgb_outofbox = XGBClassifier(random_state=0).fit(X_train, y_train)
我希望调用类似 xgb_outofbox.params_
的内容,但这不起作用。我找不到这个非常简单的问题的任何答案。
If I fit an XGBoost model on data and set none of the parameters (all are defaults), how do I then print those settings?
xgb_outofbox = XGBClassifier(random_state=0).fit(X_train, y_train)
I'm looking to call something like xgb_outofbox.params_
, but that doesn't work. I can't find any answers to this very simple question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
TL;DR
xgb_outofbox.get_params()
带有文档 此处详细信息
假设您有一个模型:“
xgb_outofbox
”带有数据:
它是一个分类器:
XGBClassifier()
并且您为其提供以下参数:
这样您就可以创建分类器:
xgb_outofbox = XGBClassifier(**params)
然后拟合数据:
xgb_outofbox.fit(X_train, y_train)
然后您就可以打印出参数,如下所示:
print(xgb_outofbox.get_params())
总而言之,代码可能如下所示:
TL;DR
xgb_outofbox.get_params()
with documentation hereThe Details
So say you have a model: "
xgb_outofbox
"With data:
It's a classifier:
XGBClassifier()
And you provide it the following parameters:
Such that you create the classifier:
xgb_outofbox = XGBClassifier(**params)
And then fit the data:
xgb_outofbox.fit(X_train, y_train)
You would then be able to print out the parameters as follows:
print(xgb_outofbox.get_params())
Altogether the code could look like this:
这可以通过打印模型对象本身来完成,即只需编写:
This can be done by printing the model object itself, i.e. just write:
使用
get_xgb_params
:它返回XGBoost特定参数。
输出将是这样的:
Use
get_xgb_params
:It returns XGBoost specific parameters.
The output would be something like this: