class_docstr: A base class for forecast estimators that fit using
  `~greykite.algo.forecast.silverkite.forecast_silverkite.SilverkiteForecast.forecast`.
  
  Notes
  -----
  Allows estimators that fit using
  `~greykite.algo.forecast.silverkite.forecast_silverkite.SilverkiteForecast.forecast`
  to share the same functions for input data validation,
  fit postprocessing, predict, summary, plot_components, etc.
  
  Subclasses should:
  
      - Implement their own ``__init__`` that uses a superset of the parameters here.
      - Implement their own ``fit``, with this sequence of steps:
  
          - calls ``super().fit``
          - calls ``SilverkiteForecast.forecast`` or ``SimpleSilverkiteForecast.forecast_simple`` and stores the result in ``self.model_dict``
          - calls ``super().finish_fit``
  
  Uses ``coverage`` to set prediction band width. Even though
  coverage is not needed by ``forecast_silverkite``, it is included
  in every ``BaseForecastEstimator`` to be used universally for
  forecast evaluation.
  
  Therefore, ``uncertainty_dict`` must be consistent with ``coverage``
  if provided as a dictionary. If ``uncertainty_dict`` is None or
  "auto", an appropriate default value is set, according to ``coverage``.
  
  Parameters
  ----------
  score_func : callable, optional, default mean_squared_error
      See `~greykite.sklearn.estimator.base_forecast_estimator.BaseForecastEstimator`.
  coverage : `float` between [0.0, 1.0] or None, optional
      See `~greykite.sklearn.estimator.base_forecast_estimator.BaseForecastEstimator`.
  null_model_params : `dict`, optional
      Dictionary with arguments to define DummyRegressor null model, default is `None`.
      See `~greykite.sklearn.estimator.base_forecast_estimator.BaseForecastEstimator`.
  uncertainty_dict : `dict` or `str` or None, optional
      How to fit the uncertainty model.
      See `~greykite.algo.forecast.silverkite.forecast_silverkite.SilverkiteForecast.forecast`.
      Note that this is allowed to be "auto". If None or "auto", will be set to
      a default value by ``coverage`` before calling ``forecast_silverkite``.
  
  Attributes
  ----------
  silverkite : Class or a derived class of `~greykite.algo.forecast.silverkite.forecast_silverkite.SilverkiteForecast`
      The silverkite algorithm instance used for forecasting
  model_dict : `dict` or None
      A dict with fitted model and its attributes.
      The output of `~greykite.algo.forecast.silverkite.forecast_silverkite.SilverkiteForecast.forecast`.
  pred_cols : `list` [`str`] or None
      Names of the features used in the model.
  feature_cols : `list` [`str`] or None
      Column names of the patsy design matrix built by
      `~greykite.algo.common.ml_models.design_mat_from_formula`.
  df : `pandas.DataFrame` or None
      The training data used to fit the model.
  coef_ : `pandas.DataFrame` or None
      Estimated coefficient matrix for the model.
      Not available for ``random forest`` and ``gradient boosting`` methods and
      set to the default value `None`.
  _pred_category : `dict` or None
      A dictionary with keys being the predictor category and
      values being the predictors belonging to the category.
      For details, see
      `~greykite.sklearn.estimator.base_silverkite_estimator.BaseSilverkiteEstimator.pred_category`.
  extra_pred_cols : `list` or None
      User provided extra predictor names, for details, see
      `~greykite.sklearn.estimator.simple_silverkite_estimator.SimpleSilverkiteEstimator`
      or
      `~greykite.sklearn.estimator.silverkite_estimator.SilverkiteEstimator`.
  past_df : `pandas.DataFrame` or None
      The extra past data before training data used to generate autoregression terms.
  forecast : `pandas.DataFrame` or None
      Output of ``predict_silverkite``, set by ``self.predict``.
  forecast_x_mat : `pandas.DataFrame` or None
      The design matrix of the model at the predict time.
  model_summary : `class` or `None`
      The `~greykite.algo.common.model_summary.ModelSummary` class.
  
  See Also
  --------
  `~greykite.algo.forecast.silverkite.forecast_silverkite.SilverkiteForecast.forecast`
      Function performing the fit and predict.
  
  Notes
  -----
  The subclasses will pass ``fs_components_df`` to ``forecast_silverkite``. The model terms
  it creates internally are used to generate the component plots.
  
      - `~greykite.common.features.timeseries_features.fourier_series_multi_fcn` uses
        ``fs_components_df["names"]`` (e.g. ``tod``, ``tow``) to build the fourier series
        and to create column names.
  
      - ``fs_components_df["seas_names"]`` (e.g. ``daily``, ``weekly``) is appended
        to the column names, if provided.
  
  `~greykite.sklearn.estimator.base_silverkite_estimator.BaseSilverkiteEstimator.plot_components` relies
  on a regular expression dictionary to group components together.  There are two available in the library, see
  `~greykite.common.constants` for the two definitions
  
      1. "DEFAULT_COMPONENTS_REGEX_DICT"
         Grouped seasonality that is the default
      2. "DETAILED_SEASONALITY_COMPONENTS_REGEX_DICT":
         A detailed seasonality breakdown where the user can view daily/weekly/monthly/quarterly/yearly seasonality
docstr: Generates silverkite forecast breakdown for groupings given in
  ``grouping_regex_patterns_dict``. Note that this only works for
  additive regression models and not for models such as random forest.
  
  Parameters
  ----------
  grouping_regex_patterns_dict : `dict` {`str`: `str`}
      A dictionary with group names as keys and regexes as values.
      This dictionary is used to partition the columns into various groups
  forecast_x_mat : `pd.DataFrame`, default None
      The dataframe of design matrix of regression model.
      If None, this will be extracted from the estimator.
  time_values : `list` or `np.array`, default None
      A collection of values (usually timestamps) to be used in the figure.
      It can also be used to join breakdown data with other data when needed.
      If None, and ``forecast_x_mat`` is not passed, timestamps will be extracted
      from the estimator to match the``forecast_x_mat`` which is also extracted
      from the estimator.
      If None, and``forecast_x_mat`` is passed, the timestamps cannot be inferred.
      Therefore we simply create an integer index with size of ``forecast_x_mat``.
  center_components : `bool`, default False
      It determines if components should be centered at their mean and the mean
      be added to the intercept. More concretely if a component is "x" then it will
      be mapped to "x - mean(x)"; and "mean(x)" will be added to the intercept so
      that the sum of the components remains the same.
  denominator : `str`, default None
      If not None, it will specify a way to divide the components. There are
      two options implemented:
  
      - "abs_y_mean" : `float`
          The absolute value of the observed mean of the response
      - "y_std" : `float`
          The standard deviation of the observed response
  
  plt_title : `str`, default "prediction breakdown"
      The title of generated plot
  
  Returns
  -------
  result : `dict`
      Dictionary returned by `~greykite.algo.common.ml_models.breakdown_regression_based_prediction`
code: def forecast_breakdown(
      self,
      grouping_regex_patterns_dict,
      forecast_x_mat=None,
      time_values=None,
      center_components=False,
      denominator=None,
      plt_title="breakdown of forecasts",
  ):
      """Generates silverkite forecast breakdown for groupings given in
      ``grouping_regex_patterns_dict``. Note that this only works for
      additive regression models and not for models such as random forest.
  
      Parameters
      ----------
      grouping_regex_patterns_dict : `dict` {`str`: `str`}
          A dictionary with group names as keys and regexes as values.
          This dictionary is used to partition the columns into various groups
      forecast_x_mat : `pd.DataFrame`, default None
          The dataframe of design matrix of regression model.
          If None, this will be extracted from the estimator.
      time_values : `list` or `np.array`, default None
          A collection of values (usually timestamps) to be used in the figure.
          It can also be used to join breakdown data with other data when needed.
          If None, and ``forecast_x_mat`` is not passed, timestamps will be extracted
          from the estimator to match the``forecast_x_mat`` which is also extracted
          from the estimator.
          If None, and``forecast_x_mat`` is passed, the timestamps cannot be inferred.
          Therefore we simply create an integer index with size of ``forecast_x_mat``.
      center_components : `bool`, default False
          It determines if components should be centered at their mean and the mean
          be added to the intercept. More concretely if a component is "x" then it will
          be mapped to "x - mean(x)"; and "mean(x)" will be added to the intercept so
          that the sum of the components remains the same.
      denominator : `str`, default None
          If not None, it will specify a way to divide the components. There are
          two options implemented:
  
          - "abs_y_mean" : `float`
              The absolute value of the observed mean of the response
          - "y_std" : `float`
              The standard deviation of the observed response
  
      plt_title : `str`, default "prediction breakdown"
          The title of generated plot
  
      Returns
      -------
      result : `dict`
          Dictionary returned by `~greykite.algo.common.ml_models.breakdown_regression_based_prediction`
      """
      # If ``forecast_x_mat`` is not passed, we assume its the
      # ``forecast_x_mat`` from the estimator.
      # In this case, we also have access to the corresponding timestamps.
      if forecast_x_mat is None:
          forecast_x_mat = self.forecast_x_mat
          time_values = self.forecast[self.model_dict["time_col"]]
  
      # If ``time_values`` is not passed or implicitly grabbed from previous step,
      # we simply create an integer index with size of ``forecast_x_mat``.
      # This will be useful in the figure x axis.
      if time_values is None:
          time_values = range(len(forecast_x_mat))
  
      return breakdown_regression_based_prediction(
          trained_model=self.model_dict,
          x_mat=forecast_x_mat,
          grouping_regex_patterns_dict=grouping_regex_patterns_dict,
          remainder_group_name="OTHER",
          center_components=center_components,
          denominator=denominator,
          index_values=time_values,
          index_col=self.model_dict["time_col"],
          plt_title=plt_title,
      )
  
imports: import re
  from typing import Dict
  from typing import Optional
  from typing import Type
  import pandas
  import plotly.express
  from pandas.tseries.frequencies import to_offset
  from plotly import graph_objects
  from plotly.subplots import make_subplots
  from sklearn.exceptions import NotFittedError
  from sklearn.metrics import mean_squared_error
  from greykite.algo.changepoint.adalasso.changepoints_utils import get_trend_changepoint_dates_from_cols
  from greykite.algo.common.col_name_utils import create_pred_category
  from greykite.algo.common.ml_models import breakdown_regression_based_prediction
  from greykite.algo.common.model_summary import ModelSummary
  from greykite.algo.forecast.silverkite.constants.silverkite_component import SilverkiteComponentsEnum
  from greykite.algo.forecast.silverkite.constants.silverkite_constant import default_silverkite_constant
  from greykite.algo.forecast.silverkite.forecast_silverkite import SilverkiteForecast
  from greykite.algo.forecast.silverkite.forecast_silverkite_helper import get_silverkite_uncertainty_dict
  from greykite.common import constants
  from greykite.common.features.timeseries_lags import min_max_lag_order
  from greykite.common.time_properties import min_gap_in_seconds
  from greykite.common.time_properties_forecast import get_simple_time_frequency_from_period
  from greykite.sklearn.estimator.base_forecast_estimator import BaseForecastEstimator
  from greykite.sklearn.uncertainty.uncertainty_methods import UncertaintyMethodEnum
label_desc: Use image node_id 6 for calling the BaseSilverkiteEstimator obj's underlying member method code with example usage: obj.forecast_breakdown(grouping_regex_patterns_dict, forecast_x_mat, time_values, center_components, denominator, plt_title) and returns: breakdown_regression_based_prediction