【发布时间】:2020-05-08 12:57:46
【问题描述】:
我注意到 XGBoost 在 Python 和 R 中的实现仅支持分类目标变量的二进制分类。
- 我已经为我的分类问题实现了随机森林和极端随机树
为什么我不能使用这种方法对来自多个类别的目标进行分类?
是否可以对我的多类数据集进行调整以使用 XGBoost?
【问题讨论】:
标签: python machine-learning decision-tree xgboost multiclass-classification
我注意到 XGBoost 在 Python 和 R 中的实现仅支持分类目标变量的二进制分类。
为什么我不能使用这种方法对来自多个类别的目标进行分类?
是否可以对我的多类数据集进行调整以使用 XGBoost?
【问题讨论】:
标签: python machine-learning decision-tree xgboost multiclass-classification
它确实支持多类分类。下面是代码:
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 作为参数进行多类分类。
【讨论】:
指定学习任务和相应的学习目标。
目标选项如下:
目标 [default=reg:squarederror]
[...]
multi:softmax:设置 XGBoost 使用 softmax 目标进行多类分类,您还需要设置 num_class(number of classes)
看起来多类分类有很多选择,只需选择你的武器:)
【讨论】: