Skip to content

Commit 5e65c54

Browse files
author
Rijk van der Meulen
committed
unit8co#1545 update docstrings for correctness API reference docs
1 parent 95218df commit 5e65c54

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

darts/explainability/explainability.py

+5
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ def explain(
262262
This series has length 3, as the model can explain 5-3+1 forecasts
263263
(timestamp indexes 4, 5, and 6)
264264
265+
Note, it's also possible to retrieve the feature values corresponding to the explanation via the method
266+
:func:`ExplainabilityResult.get_feature_values(horizon, target_component)`. Finally, one can use the
267+
:func:`ExplainabilityResult.get_shap_explanation_object(horizon, target_component)` to retrieve the
268+
corresponding SHAP explanation object.
269+
265270
Parameters
266271
----------
267272
foreground_series

darts/explainability/explainability_result.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
def check_input_validity_for_querying_explainability_result(func: Callable) -> Callable:
2222
"""
23-
A decorator that validates the input parameters of a method that query the ExplainabilityResult (e.g.,
24-
get_explanation(), get_feature_values()).
23+
A decorator that validates the input parameters of a method that queries the ExplainabilityResult (i.e.,
24+
get_explanation(), get_feature_values(), and get_shap_explanation_object).
2525
"""
2626

2727
@wraps(func)
@@ -73,7 +73,6 @@ def __init__(
7373
Dict[integer, Dict[str, TimeSeries]],
7474
Sequence[Dict[integer, Dict[str, TimeSeries]]],
7575
],
76-
# Original SHAP explanation object in case SHAP is used by ForecastingModelExplainer
7776
shap_explanation_object: Optional[
7877
Union[
7978
Dict[integer, Dict[str, shap.Explanation]],
@@ -131,7 +130,7 @@ def get_feature_values(
131130
horizon
132131
The horizon for which to return the feature values.
133132
component
134-
The component for which to return the explanation. Does not
133+
The component for which to return the feature values. Does not
135134
need to be specified for univariate series.
136135
"""
137136
if isinstance(self.feature_values, list):
@@ -147,14 +146,15 @@ def get_shap_explanation_object(
147146
self, horizon: int, component: Optional[str] = None
148147
) -> Union[shap.Explanation, Sequence[shap.Explanation]]:
149148
"""
150-
Returns one or several shap.Explanations objects for a given horizon and component.
149+
In case, SHAP is used by the :class:`ForecastingModelExplainer` to explain the forecast, this method
150+
returns the underlying `shap.Explanations` object(s) for a given horizon and component.
151151
152152
Parameters
153153
----------
154154
horizon
155-
The horizon for which to return the feature values.
155+
The horizon for which to return the `shap.Explanations` object(s).
156156
component
157-
The component for which to return the explanation. Does not
157+
The component for which to return the `shap.Explanations` object(s). Does not
158158
need to be specified for univariate series.
159159
"""
160160
if not self.shap_explanation_object:

0 commit comments

Comments
 (0)