darts.explainability.utils.get_component_names(series, past_covariates=None, future_covariates=None, idx=0)[source]

Extract and return the components of target series, static covariate, past and future covariates series.

Parameters
  • model – any ForecastingModel.

  • series (Sequence[TimeSeries]) – A sequence of target TimeSeries.

  • past_covariates (Optional[Sequence[TimeSeries]]) – Optionally, a sequence of past covariates TimeSeries.

  • future_covariates (Optional[Sequence[TimeSeries]]) – Optionally, a sequence of future covariates TimeSeries.

  • idx (int) – the index of the input sequences to extract the components from.

Return type

Tuple[List[str], Optional[List[str]], Optional[List[str]], Optional[List[str]]]

darts.explainability.utils.process_horizons_and_targets(horizons=None, fallback_horizon=None, target_components=None, fallback_target_components=None, check_component_names=False)[source]

Processes the input horizons and target component names.

horizons

Optionally, an integer or sequence of integers representing the future time steps to be explained. 1 corresponds to the first timestamp being forecasted. All values must be <=output_chunk_length of the explained forecasting model.

fallback_horizon

Optionally, a horizon to fall back to in case horizons was not provided.

target_components

Optionally, a string or sequence of strings with the target components to explain.

fallback_target_components

Optionally, a sequence of strings to fall back to in case target_components was not provided.

check_component_names

Whether to enforce that the target components are in fallback_target_component.

Return type

Tuple[Sequence[int], Sequence[str]]

darts.explainability.utils.process_input(model, input_type, series=None, past_covariates=None, future_covariates=None, fallback_series=None, fallback_past_covariates=None, fallback_future_covariates=None, check_component_names=False, requires_input=True, requires_covariates_encoding=False, test_stationarity=False)[source]

Helper function to process and check either of the background or foreground series input to _ForecastingModelExplainer.

If no input was provided (series, past/future_covariates), the fallback will be used for downstream tasks. Will raise an error if both input and fallback are not available.

The fallback is dependent on the input type (“background” or “foreground”): - for background input_type: fallback are the series saved in fitted forecasting model - for foreground input_type: fallback are the background series from _ForecastingModelExplainer

Parameters
  • model (ForecastingModel) – any ForecastingModel.

  • input_type (str) – the type of input series. Either “background” or “foreground”

  • series (Union[TimeSeries, Sequence[TimeSeries], None]) – Optionally, one or a sequence of target TimeSeries.

  • past_covariates (Union[TimeSeries, Sequence[TimeSeries], None]) – Optionally, one or a sequence of past covariates TimeSeries.

  • future_covariates (Union[TimeSeries, Sequence[TimeSeries], None]) – Optionally, one or a sequence of future covariates TimeSeries.

  • fallback_series (Union[TimeSeries, Sequence[TimeSeries], None]) – Optionally, one or a sequence of target TimeSeries to fall back to in case series was not provided.

  • fallback_past_covariates (Union[TimeSeries, Sequence[TimeSeries], None]) – Optionally, one or a sequence of past covariates TimeSeries to fall back to in case past_covariates was not provided.

  • fallback_future_covariates (Union[TimeSeries, Sequence[TimeSeries], None]) – Optionally, one or a sequence of future covariates TimeSeries to fall back to in case future_covariates was not provided.

  • check_component_names (bool) – Whether to enforce that, in the case of multiple time series, all series of the same type (target or *_covariates) must have the same component names.

  • requires_input (bool) – Whether the input is required. If True, raises an error if no input was provided.

  • requires_covariates_encoding (bool) – Whether to apply the model’s encoders to the input covariates. This should only be True if the Explainer will not call model methods fit() or predict() directly.

  • test_stationarity (bool) – Whether to raise a warning if not all components from the target series are stationary.