如何从XGBoost(XGBClassifier)获取/返回max_depth参数?

发布于 2025-02-01 03:24:05 字数 880 浏览 3 评论 0原文

我训练了幼稚的XGBClassifier()。安装我的分类器后具有参数:

XGBClassifier(base_score=0.5, booster='gbtree', callbacks=None,
              colsample_bylevel=1, colsample_bynode=1, colsample_bytree=1,
              early_stopping_rounds=None, enable_categorical=False,
              eval_metric=None, gamma=0, gpu_id=-1, grow_policy='depthwise',
              importance_type=None, interaction_constraints='',
              learning_rate=0.300000012, max_bin=256, max_cat_to_onehot=4,
              max_delta_step=0, max_depth=6, max_leaves=0, min_child_weight=1,
              missing=nan, monotone_constraints='()', n_estimators=10, n_jobs=0,
              num_parallel_tree=1, objective='binary:logistic',
              predictor='auto', random_state=0, reg_alpha=0, ...)

如何获得max_depth参数? 如果我跑步:

xgbc_naive.max_depth

我一无所获。 有什么想法吗?

I trained naive XGBClassifier(). After fitting my classifier has params:

XGBClassifier(base_score=0.5, booster='gbtree', callbacks=None,
              colsample_bylevel=1, colsample_bynode=1, colsample_bytree=1,
              early_stopping_rounds=None, enable_categorical=False,
              eval_metric=None, gamma=0, gpu_id=-1, grow_policy='depthwise',
              importance_type=None, interaction_constraints='',
              learning_rate=0.300000012, max_bin=256, max_cat_to_onehot=4,
              max_delta_step=0, max_depth=6, max_leaves=0, min_child_weight=1,
              missing=nan, monotone_constraints='()', n_estimators=10, n_jobs=0,
              num_parallel_tree=1, objective='binary:logistic',
              predictor='auto', random_state=0, reg_alpha=0, ...)

How can I get max_depth parameter?
If I run:

xgbc_naive.max_depth

I get None.
Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何时共饮酒 2025-02-08 03:24:05

这应该是正确的,如果您的型号名称为XGBC_NAIVE,并且培训进行得很好,

这些都应显示Max_depth

model.get_params   
model.get_xgb_params
model.max_depth    # should show max_depth used

您是否训练了您是否使用:

xgbc_naive = XGBClassifier(etc, etc)

PS如果您保存模型并使用load_model再次加载了型号,请尝试:

model.score  # show a list of the params used

That should be correct, if your model name is xgbc_naive and training went well

These should all show the max_depth

model.get_params   
model.get_xgb_params
model.max_depth    # should show max_depth used

Did you train with :

xgbc_naive = XGBClassifier(etc, etc)

P.S. if you saved your model and loaded it again using load_model, try:

model.score  # show a list of the params used

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文