【问题标题】:XGBoost - get probabilities after multi:softmax functionXGBoost - 获得 multi:softmax 函数后的概率
【发布时间】:2019-02-26 22:52:06
【问题描述】:

我有一个关于 xgboost 和 multiclass 的问题。我没有使用 sklearn 包装器,因为我总是与一些参数作斗争。我正在考虑是否有可能获得概率向量加上 softmax 输出。以下是我的代码:

param = {}
param['objective'] = 'multi:softmax'
param['booster'] = 'gbtree'
param['eta'] = 0.1
param['max_depth'] = 30
param['silent'] = 1
param['nthread'] = 4
param['num_round'] = 40
param['num_class'] = len(np.unique(label)) + 1   
model = xgb.train(param, dtrain)                                    
# predict                                                                                   
pred = model.predict(dtest)

我希望能够调用像predict_proba 这样的函数,但我不知道是否可以。很多答案(例如:https://datascience.stackexchange.com/questions/14527/xgboost-predict-probabilities)建议移动到 sklearn 包装器,但是,我想保持正常的火车方法。

【问题讨论】:

    标签: python xgboost xgbclassifier


    【解决方案1】:

    如果您使用param['objective'] = 'multi:prob' 而不是param['objective'] = 'multi:softmax',则分类器的结果是每个类的概率。

    请参阅此处的文档: https://xgboost.readthedocs.io/en/latest/parameter.html#learning-task-parameters

    【讨论】:

    • 它是'multi:softprob'
    猜你喜欢
    • 2017-06-11
    • 2020-02-02
    • 1970-01-01
    • 1970-01-01
    • 2015-09-21
    • 2020-05-07
    • 1970-01-01
    • 2020-08-07
    • 1970-01-01
    相关资源
    最近更新 更多