class_docstr: A base class for forecast models. Fits a timeseries and predicts future values
  
  Parameters
  ----------
  score_func : callable, optional, default=mean_squared_error
      Function to calculate model R2_null_model_score score,
      with signature (actual, predicted).
      `actual`, `predicted` are array-like with the same shape.
      Smaller values are better.
  
  coverage : float, optional, default=0.95
      intended coverage of the prediction bands (0.0 to 1.0)
      If None, the upper/lower predictions are not returned by `predict`
  
      Every subclass must use `coverage` to set prediction band width. This ensures a common
      BaseForecastEstimator interface for parameters used during fitting and forecast evaluation
  
  null_model_params : dict with arguments passed to DummyRegressor, optional, default=None
      Dictionary keys must be in ("strategy", "constant", "quantile")
      Defines null model. model score is R2_null_model_score of model error relative to null model, evaluated by score_func
      If None, model score is score_func of the model itself
  
  Attributes
  ----------
  null_model : DummyEstimator
      null model used to measure model score
  time_col_ : str
      Name of input data time column
  value_col_ : str
      Name of input data value column
  last_predicted_X_ : `pandas.DataFrame` or None
      The ``X`` last passed to ``self.predict()``.
      Used to speed up predictions if the same ``X`` is passed repeatedly.
      Resets to None when ``self.fit()`` is called.
  cached_predictions_ : `pandas.DataFrame` or None
      The return value of the last call to ``self.predict()``.
      Used to speed up predictions if the same ``X`` is passed repeatedly.
      Resets to None when ``self.fit()`` is called.
class_docstr_tok: ["A","base","class","for","forecast","models",".","Fits","a","timeseries","and","predicts","future","values","Parameters","--","--","--","--","--","score_func",":","callable",",","optional",",","default=mean_squared_error","Function","to","calculate","model","R2_null_model_score","score",",","with","signature","(","actual",",","predicted",")",".","`","actual","`",",","`","predicted","`","are","array-like","with","the","same","shape",".","Smaller","values","are","better",".","coverage",":","float",",","optional",",","default=0.95","intended","coverage","of","the","prediction","bands","(","0.0","to","1.0",")","If","None",",","the","upper\/lower","predictions","are","not","returned","by","`","predict","`","Every","subclass","must","use","`","coverage","`","to","set","prediction","band","width",".","This","ensures","a","common","BaseForecastEstimator","interface","for","parameters","used","during","fitting","and","forecast","evaluation","null_model_params",":","dict","with","arguments","passed","to","DummyRegressor",",","optional",",","default=None","Dictionary","keys","must","be","in","(","``","strategy","''",",","``","constant","''",",","``","quantile","''",")","Defines","null","model",".","model","score","is","R2_null_model_score","of","model","error","relative","to","null","model",",","evaluated","by","score_func","If","None",",","model","score","is","score_func","of","the","model","itself","Attributes","--","--","--","--","--","null_model",":","DummyEstimator","null","model","used","to","measure","model","score","time_col_",":","str","Name","of","input","data","time","column","value_col_",":","str","Name","of","input","data","value","column","last_predicted_X_",":","`","pandas.DataFrame","`","or","None","The","``","X","``","last","passed","to","``","self.predict","(",")","``",".","Used","to","speed","up","predictions","if","the","same","``","X","``","is","passed","repeatedly",".","Resets","to","None","when","``","self.fit","(",")","``","is","called",".","cached_predictions_",":","`","pandas.DataFrame","`","or","None","The","return","value","of","the","last","call","to","``","self.predict","(",")","``",".","Used","to","speed","up","predictions","if","the","same","``","X","``","is","passed","repeatedly",".","Resets","to","None","when","``","self.fit","(",")","``","is","called","."]
docstr: Fits the uncertainty model with a given ``df`` and ``uncertainty_dict``.
  
  Parameters
  ----------
  df : `pandas.DataFrame`
      A dataframe representing the data to fit the uncertainty model.
  uncertainty_dict : `dict` [`str`, any]
      The uncertainty model specification. It should have the following keys:
  
          "uncertainty_method": a string that is in
              `~greykite.sklearn.uncertainty.uncertainty_methods.UncertaintyMethodEnum`.
          "params": a dictionary that includes any additional parameters needed by the uncertainty method.
  
  fit_params : `dict` [`str`, any] or None, default None
      Parameters to be passed to the ``fit`` function.
  kwargs : additional parameters to be fed into the uncertainty method.
      These parameters are from the estimator attributes, not given by user.
  
  Returns
  -------
  The function sets ``self.uncertainty_model`` and does not return anything.
docstr_tok: ["Fits","the","uncertainty","model","with","a","given","``","df","``","and","``","uncertainty_dict","``",".","Parameters","--","--","--","--","--","df",":","`","pandas.DataFrame","`","A","dataframe","representing","the","data","to","fit","the","uncertainty","model",".","uncertainty_dict",":","`","dict","`","[","`","str","`",",","any","]","The","uncertainty","model","specification",".","It","should","have","the","following","keys",":","``","uncertainty_method","''",":","a","string","that","is","in","`","~greykite.sklearn.uncertainty.uncertainty_methods.UncertaintyMethodEnum","`",".","``","params","''",":","a","dictionary","that","includes","any","additional","parameters","needed","by","the","uncertainty","method",".","fit_params",":","`","dict","`","[","`","str","`",",","any","]","or","None",",","default","None","Parameters","to","be","passed","to","the","``","fit","``","function",".","kwargs",":","additional","parameters","to","be","fed","into","the","uncertainty","method",".","These","parameters","are","from","the","estimator","attributes",",","not","given","by","user",".","Returns","--","--","--","-","The","function","sets","``","self.uncertainty_model","``","and","does","not","return","anything","."]
code: def fit_uncertainty(
      self,
      df: pd.DataFrame,
      uncertainty_dict: dict,
      fit_params: Optional[dict] = None,
      **kwargs,
  ):
      """Fits the uncertainty model with a given ``df`` and ``uncertainty_dict``.
  
      Parameters
      ----------
      df : `pandas.DataFrame`
          A dataframe representing the data to fit the uncertainty model.
      uncertainty_dict : `dict` [`str`, any]
          The uncertainty model specification. It should have the following keys:
  
              "uncertainty_method": a string that is in
                  `~greykite.sklearn.uncertainty.uncertainty_methods.UncertaintyMethodEnum`.
              "params": a dictionary that includes any additional parameters needed by the uncertainty method.
  
      fit_params : `dict` [`str`, any] or None, default None
          Parameters to be passed to the ``fit`` function.
      kwargs : additional parameters to be fed into the uncertainty method.
          These parameters are from the estimator attributes, not given by user.
  
      Returns
      -------
      The function sets ``self.uncertainty_model`` and does not return anything.
      """
      # When ``uncertainty_dict`` is not provided but ``self.coverage`` is provided,
      # it falls back to the "simple conditional residuals" uncertainty method.
      if (
          uncertainty_dict is None or uncertainty_dict == {}
      ) and self.coverage is not None:
          uncertainty_dict = dict(
              uncertainty_method=UncertaintyMethodEnum.simple_conditional_residuals.name,
              params=dict(
                  value_col=self.value_col_,
                  is_residual_based=True,
                  offset_col=cst.PREDICTED_COL,
              ),
          )
      # Gets the uncertainty method.
      if uncertainty_dict is not None:
          uncertainty_method = uncertainty_dict.get(
              "uncertainty_method", None
          )
      else:
          uncertainty_method = None
      # Tries to find the uncertainty method from Enum.
      if uncertainty_method is not None:
          try:
              uncertainty_model = UncertaintyMethodEnum[
                  uncertainty_method
              ].value.model_class
          except (KeyError, AttributeError):
              # If not found in Enum, do not stop, return.
              # The ``self.uncertainty_model`` is not set and will not be used in prediction.
              log_message(
                  message=f"Uncertainty method {uncertainty_method} is not found in `UncertaintyMethodEnum`, "
                  f"uncertainty fitting is skipped. Valid methods are "
                  f"{', '.join(UncertaintyMethodEnum.__dict__['_member_names_'])}.",
                  level=LoggingLevelEnum.WARNING,
              )
              return
          uncertainty_dict = self._populate_uncertainty_params(
              uncertainty_dict
          )
          # Tries to fit the model. If ``UncertaintyError`` happened,
          # catch it and do not raise an error.
          try:
              self.uncertainty_model = uncertainty_model(
                  uncertainty_dict=uncertainty_dict,
                  time_col=self.time_col_,
                  coverage=self.coverage,
                  **kwargs,
              )
              if fit_params is None:
                  fit_params = {}
              self.uncertainty_model.fit(df, **fit_params)
          except UncertaintyError as e:
              self.uncertainty_model = None
              log_message(
                  message=f"The following errors occurred during fitting the uncertainty model, "
                  f"the uncertainty model is skipped. {e}",
                  level=LoggingLevelEnum.WARNING,
              )
  
imports: from abc import ABC
  from abc import abstractmethod
  from typing import Optional
  import pandas
  from sklearn.base import BaseEstimator
  from sklearn.base import RegressorMixin
  from sklearn.metrics import mean_squared_error
  from greykite.common import constants
  from greykite.common.evaluation import r2_null_model_score
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.sklearn.estimator.null_model import DummyEstimator
  from greykite.sklearn.uncertainty.exceptions import UncertaintyError
  from greykite.sklearn.uncertainty.uncertainty_methods import UncertaintyMethodEnum
label_desc: Use image node_id 6 for calling the BaseForecastEstimator obj's underlying member method code with example usage: obj.fit_uncertainty(df, uncertainty_dict, fit_params) without return types