xgboost Scala API 什么是 `predictContrib`?

xgboost Scala API what is `predictContrib`?

我正在使用 xgboost 和 scala API。

我曾经将 xgboostRpython API 一起使用,最近我发现了 pred_contribs 参数。

例如,在 python API 中,文档说:

When this is True the output will be a matrix of size (nsample, nfeats + 1) with each record indicating the feature contributions (SHAP values) for that prediction. The sum of all feature contributions is equal to the raw untransformed margin value of the prediction. Note the final column is the bias term.

据我了解,是一种Tree SHAP直接在xgboost中实现的

我的问题是:

predictContrib 在 Scala 中是一样的 API ?

是的,这完全一样,因为两者最终都执行相同的代码。

Python: https://github.com/dmlc/xgboost/blob/master/python-package/xgboost/core.py#L1239

斯卡拉:

  1. 开头为 JBooster
  2. 那个叫XGBoostJNI.XGBoosterPredict

最后两个调用相同C API