[Feature] Expose TreeShap feature contribution

The method to calculate shapely values via TreeShap has been added. However, it is not yet exposed in cli_main for people to use it to get feature importance values for prediction.
The functionality has been added in tree_model.cc
Can I add that to the cli_main for usage?

It’s available from Python and R bindings. Do you mean the CLI?

Yes, I meant the CLI.

How can you obtain SHAP values directly from XGBoost API without using the dedicated SHAP package?

import pandas as pd
from sklearn.datasets import load_boston
import xgboost as xgb

data = load_boston()

X = pd.DataFrame(data.data, columns=data.feature_names)
y = pd.Series(data.target)

model = xgb.XGBRegressor(random_state=1,
                         n_estimators=1,  # 只有一棵树
model.fit(X, y)