gpt4 book ai didi

python - 为什么XGBoost只支持二元分类

转载 作者:行者123 更新时间:2023-11-30 09:58:54 24 4
gpt4 key购买 nike

我注意到 Python 和 R 中的 XGBoost 实现仅支持分类目标变量的二元分类。

  • 我已经为我的分类问题实现了随机森林和极度随机树

为什么我不能使用此方法对来自多个类别的目标进行分类?

是否可以对我的多类数据集进行调整才能使用 XGBoost?

最佳答案

它确实支持多类分类。下面是代码:

param = {
'max_depth': 3, # the maximum depth of each tree
'eta': 0.3, # the training step for each iteration
'silent': 1, # logging mode - quiet
'objective': 'multi:softprob', # error evaluation for multiclass training
'num_class': 3} # the number of classes that exist in this dataset

您可以在 Python 中使用 num_class 作为参数进行多类分类。

关于python - 为什么XGBoost只支持二元分类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59858482/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com