Unverified Commit b09c1ff7 authored by Belinda Trotta's avatar Belinda Trotta Committed by GitHub
Browse files

[DOCS] Update docs to note that pred_contrib is not available for linear trees (#4006)

* Update docs to note that pred_contrib is not available for linear trees

* Add warning in code

* Change warning to error
parent 71715584
...@@ -863,6 +863,8 @@ Predict Parameters ...@@ -863,6 +863,8 @@ Predict Parameters
- **Note**: unlike the shap package, with ``predict_contrib`` we return a matrix with an extra column, where the last column is the expected value - **Note**: unlike the shap package, with ``predict_contrib`` we return a matrix with an extra column, where the last column is the expected value
- **Note**: this feature is not implemented for linear trees
- ``predict_disable_shape_check`` :raw-html:`<a id="predict_disable_shape_check" title="Permalink to this parameter" href="#predict_disable_shape_check">&#x1F517;&#xFE0E;</a>`, default = ``false``, type = bool - ``predict_disable_shape_check`` :raw-html:`<a id="predict_disable_shape_check" title="Permalink to this parameter" href="#predict_disable_shape_check">&#x1F517;&#xFE0E;</a>`, default = ``false``, type = bool
- used only in ``prediction`` task - used only in ``prediction`` task
......
...@@ -747,6 +747,7 @@ struct Config { ...@@ -747,6 +747,7 @@ struct Config {
// desc = produces ``#features + 1`` values where the last value is the expected value of the model output over the training data // desc = produces ``#features + 1`` values where the last value is the expected value of the model output over the training data
// desc = **Note**: if you want to get more explanation for your model's predictions using SHAP values like SHAP interaction values, you can install `shap package <https://github.com/slundberg/shap>`__ // desc = **Note**: if you want to get more explanation for your model's predictions using SHAP values like SHAP interaction values, you can install `shap package <https://github.com/slundberg/shap>`__
// desc = **Note**: unlike the shap package, with ``predict_contrib`` we return a matrix with an extra column, where the last column is the expected value // desc = **Note**: unlike the shap package, with ``predict_contrib`` we return a matrix with an extra column, where the last column is the expected value
// desc = **Note**: this feature is not implemented for linear trees
bool predict_contrib = false; bool predict_contrib = false;
// [no-save] // [no-save]
......
...@@ -85,6 +85,9 @@ class Predictor { ...@@ -85,6 +85,9 @@ class Predictor {
} }
}; };
} else if (predict_contrib) { } else if (predict_contrib) {
if (boosting_->IsLinear()) {
Log::Fatal("Predicting SHAP feature contributions is not implemented for linear trees.");
}
predict_fun_ = [=](const std::vector<std::pair<int, double>>& features, predict_fun_ = [=](const std::vector<std::pair<int, double>>& features,
double* output) { double* output) {
int tid = omp_get_thread_num(); int tid = omp_get_thread_num();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment