Commit 89f2021a authored by Scott Lundberg's avatar Scott Lundberg Committed by Nikita Titov
Browse files

[docs] Update doc string for pred_contrib (#2116)

* Update doc string for pred_contrib

See comments at the end of #1969

* Update basic.py

* Update basic.py

* update doc strings

* update equals sign in doc string

* strip whitespace and gen rst

* strip whitespace
parent beb35d56
......@@ -633,6 +633,8 @@ IO Parameters
- **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>`__
- **Note**: unlike the shap package, with ``pred_contrib`` we return a matrix with an extra column, where the last column is the expected value.
- ``num_iteration_predict`` :raw-html:`<a id="num_iteration_predict" title="Permalink to this parameter" href="#num_iteration_predict">&#x1F517;&#xFE0E;</a>`, default = ``-1``, type = int
- used only in ``prediction`` task
......
......@@ -588,6 +588,7 @@ struct Config {
// desc = set this to ``true`` to estimate `SHAP values <https://arxiv.org/abs/1706.06060>`__, which represent how each feature contributes to each prediction
// 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**: unlike the shap package, with ``pred_contrib`` we return a matrix with an extra column, where the last column is the expected value.
bool predict_contrib = false;
// desc = used only in ``prediction`` task
......
......@@ -2261,9 +2261,11 @@ class Booster(object):
Note
----
If you want to get more explanation for your model's predictions using SHAP values
If you want to get more explanations for your model's predictions using SHAP values,
like SHAP interaction values,
you can install shap package (https://github.com/slundberg/shap).
you can install the shap package (https://github.com/slundberg/shap).
Note that unlike the shap package, with ``pred_contrib`` we return a matrix with an extra
column, where the last column is the expected value.
data_has_header : bool, optional (default=False)
Whether the data has header.
......
......@@ -582,9 +582,11 @@ class LGBMModel(_LGBMModelBase):
Note
----
If you want to get more explanation for your model's predictions using SHAP values
If you want to get more explanations for your model's predictions using SHAP values,
like SHAP interaction values,
you can install shap package (https://github.com/slundberg/shap).
you can install the shap package (https://github.com/slundberg/shap).
Note that unlike the shap package, with ``pred_contrib`` we return a matrix with an extra
column, where the last column is the expected value.
**kwargs
Other parameters for the prediction.
......@@ -593,10 +595,10 @@ class LGBMModel(_LGBMModelBase):
-------
predicted_result : array-like of shape = [n_samples] or shape = [n_samples, n_classes]
The predicted values.
X_leaves : array-like of shape = [n_samples, n_trees] or shape [n_samples, n_trees * n_classes]
X_leaves : array-like of shape = [n_samples, n_trees] or shape = [n_samples, n_trees * n_classes]
If ``pred_leaf=True``, the predicted leaf every tree for each sample.
X_SHAP_values : array-like of shape = [n_samples, n_features + 1] or shape [n_samples, (n_features + 1) * n_classes]
If ``pred_contrib=True``, the each feature contributions for each sample.
X_SHAP_values : array-like of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes]
If ``pred_contrib=True``, the feature contributions for each sample.
"""
if self._n_features is None:
raise LGBMNotFittedError("Estimator not fitted, call `fit` before exploiting the model.")
......@@ -785,9 +787,11 @@ class LGBMClassifier(LGBMModel, _LGBMClassifierBase):
Note
----
If you want to get more explanation for your model's predictions using SHAP values
If you want to get more explanations for your model's predictions using SHAP values,
like SHAP interaction values,
you can install shap package (https://github.com/slundberg/shap).
you can install the shap package (https://github.com/slundberg/shap).
Note that unlike the shap package, with ``pred_contrib`` we return a matrix with an extra
column, where the last column is the expected value.
**kwargs
Other parameters for the prediction.
......@@ -797,9 +801,9 @@ class LGBMClassifier(LGBMModel, _LGBMClassifierBase):
predicted_probability : array-like of shape = [n_samples, n_classes]
The predicted probability for each class for each sample.
X_leaves : array-like of shape = [n_samples, n_trees * n_classes]
If ``pred_leaf=True``, the predicted leaf every tree for each sample.
If ``pred_leaf=True``, the predicted leaf of every tree for each sample.
X_SHAP_values : array-like of shape = [n_samples, (n_features + 1) * n_classes]
If ``pred_contrib=True``, the each feature contributions for each sample.
If ``pred_contrib=True``, the feature contributions for each sample.
"""
result = super(LGBMClassifier, self).predict(X, raw_score, num_iteration,
pred_leaf, pred_contrib, **kwargs)
......
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