【问题标题】:Using XGBoost to predict importance or percentage based on inputs使用 XGBoost 根据输入预测重要性或百分比
【发布时间】:2017-10-31 05:03:55
【问题描述】:

我正在解释我的 XGBoost 模型。以下面两个数据集trainInput和trainOutput为例:

df.trainInputs
    input1 input2 input3
0      1     0      0
1      1     1      0
2      0     1      1
..

df.trainOutputs
      output
0       1   
1       0
2       1
...

用户输入已经过一次热编码,输出数据是用户输出模式的列表。我正在用这些训练我的 XGBoost 模型,然后根据来自另一个数据集的单热编码用户输入数据的另一个矩阵进行预测。我希望检索列的每个元素的百分比分数,但是在运行我的模型时,我只接收二进制输出。在构建模型时我缺少什么吗?相关代码:

df.predictInputs
    input1 input2 input3
0      1     1      0
1      1     0      0
2      1     0      1
..

model = xgb.XGBClassifier()
model.fit(trainInputs, trainOutput)
y_pred = model.predict(predictOutput)

【问题讨论】:

  • 你为什么把predictOutput作为model.predict的参数?不应该是predictOutputs = model.predict(testInputs) 之类的东西吗?然后您可以将predictOutputs 与实际输出进行比较,以查看正确的百分比。
  • 抱歉,这是我的错字 - 我使用的是predictInputs。我担心predictOutputs 的结果是返回二进制而不是百分比,但我可能错过了一步。

标签: python pandas machine-learning xgboost


【解决方案1】:

如果要获取结果概率(每个元素的百分比分数),请使用predict_proba 而不是predict。

【讨论】:

    猜你喜欢
    • 2017-07-25
    • 1970-01-01
    • 2020-05-16
    • 2020-12-03
    • 2021-11-15
    • 1970-01-01
    • 2012-11-26
    • 1970-01-01
    • 2019-12-16
    相关资源
    最近更新 更多