class_docstr: The quantile regression based uncertainty model.
  Predicts quantiles as the prediction intervals.
  The quantiles are calculated based on the ``coverage`` parameter.
  For example, a 90% prediction interval is the 0.05 quantile and 0.95 quantile predictions.
  
  There are four scenarios:
  
      - ``is_residual_based = False`` and ``x_mat`` is provided.
        In this case, the method fits two quantile regression models based on the ``value_col`` and ``x_mat``.
        Depending on the forecast model, the generated prediction intervals may not cover the forecasted values.
      - ``is_residual_based = False`` and ``x_mat`` is not provided.
        In this case, a ``x_mat`` is generated based on ``time_col``
        including linear growth and yearly/weekly seasonality.
        Currently we do not support customizing the generation of this feature matrix.
        The method fits two quantile regression models based on ``value_col`` and the generated ``x_mat``.
        Depending on the forecast model, the generated prediction intervals may not cover the forecasted values.
      - ``is_residual_based = True`` and ``x_mat`` is provided.
        In this case, the ``predicted_col`` needs to be provided
        in addition to ``value_col`` to calculate the residuals.
        The method fits two quantile regression models based on the residuals and ``x_mat``.
        The fitted residual quantiles are added to the forecasted values.
      - ``is_residual_based = True`` and ``x_mat`` is not provided.
        In this case, the ``predicted_col`` needs to be provided
        in addition to ``value_col`` to calculate the residuals.
        In this case, a ``x_mat`` is generated based on ``time_col``
        including linear growth and yearly/weekly seasonality.
        Currently we do not support customizing the generation of this feature matrix.
        The method fits two quantile regression models based on residuals and the generated ``x_mat``.
        The fitted residual quantiles are added to the forecasted values.
  
  If ``x_mat`` is not provided, ``time_col`` must be provided to build the feature matrix.
  
  If ``is_residual_based = False``, then ``value_col`` must be provided to train the model.
  If ``is_residual_based = True``, then both ``value_col`` and ``predicted_col`` must be provided.
  In this case, the method also tries to find ``cst.PREDICTED_COL`` in the training data
  too if ``predicted_col`` is not provided.
  
  Attributes
  ----------
  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.
                        Expected keys include: "value_col", "predicted_col", "is_residual_based"
                        and "quantiles".
  
  UNCERTAINTY_METHOD : `str`
      The name for the uncertainty method.
  REQUIRED_PARAMS : `list` [`str`]
      A list of required parameters for the method.
  coverage : `float`
      The coverage of the uncertainty intervals.
      Will be used to calculate the quantiles.
  time_col : `str`
      The column name for timestamps in ``train_df`` and ``fut_df``.
  value_col : `str` or None
      The column name for values in ``train_df`` and ``fut_df``.
  predicted_col : `str` or None
      The column name for predicted values in ``train_df`` and ``fut_df``.
  residual_col : `str` or None
      The column name for residuals in ``train_df``.
  quantiles : `list` [`float`] or None
      A list of quantiles to be fitted.
      This is also derived from the ``coverage`` parameter.
  is_residual_based : `bool` or None
      Whether to fit the original values or residuals.
  models : `list` [`QuantileRegression`] or None
      A list of trained quantile regression models.
  x_mat : `pandas.DataFrame` or None
      The feature matrix used to fit the model.
  build_x_mat : `bool` or None
      Whether the feature matrix is built. If False, it is provided.
  distribution_col : `str` or None
      The column name for the column used as response in fitting the quantile regression models.
  offset_col : `str` or None
      The column name for the column used to offset the predicted intervals.
docstr: Checks that necessary input are provided in ``self.uncertainty_dict`` and ``self.train_df``.
  This check only raises
  `~greykite.sklearn.uncertainty.exceptions.UncertaintyError`.
docstr_tok: ["Checks","that","necessary","input","are","provided","in","``","self.uncertainty_dict","``","and","``","self.train_df","``",".","This","check","only","raises","`","~greykite.sklearn.uncertainty.exceptions.UncertaintyError","`","."]
code: def _check_input(self):
      """Checks that necessary input are provided in ``self.uncertainty_dict`` and ``self.train_df``.
      This check only raises
      `~greykite.sklearn.uncertainty.exceptions.UncertaintyError`.
      """
      super()._check_input()
  
      # Gets whether it's residual based.
      # If not provided, the default is not residual based.
      self.is_residual_based = self.params.get(
          "is_residual_based", False
      )
  
      # Checks value column.
      self.value_col = self.params.get("value_col")
      if self.value_col not in self.train_df:
          raise UncertaintyError(
              f"`value_col` {self.value_col} not found in `train_df`."
          )
  
      # Checks columns needed when ``is_residual_based = True``.
      # If residual based, ``predicted_col`` must be provided.
      # Also looks for ``cst.PREDICTED_COL`` if the above is not provided.
      self.distribution_col = self.value_col
      if self.is_residual_based:
          # Tries to get predicted column from parameters and set ``offset_col``.
          self.predicted_col = self.params.get("predicted_col")
          if self.predicted_col is None:
              if cst.PREDICTED_COL in self.train_df.columns:
                  self.predicted_col = cst.PREDICTED_COL
              else:
                  raise UncertaintyError(
                      f"`predicted_col` is needed for offsetting predictions when "
                      f"`is_residual_based=True`, but it is not provided."
                  )
          self.offset_col = self.predicted_col
  
          # Creates ``residual_col`` with ``value_col`` and ``predicted_col``.
          self.residual_col = cst.RESIDUAL_COL
          self.distribution_col = self.residual_col
          self.train_df[cst.RESIDUAL_COL] = (
              self.train_df[self.value_col]
              - self.train_df[self.predicted_col]
          )
  
      # Checks columns needed when ``x_mat`` is not provided.
      # This includes the time column.
      self.build_x_mat = False
      if self.x_mat is None:
          self.build_x_mat = (
              True  # Flag to build x mat in the prediction phase too
          )
          if self.time_col is None:
              self.time_col = self.params.get("time_col")
          if self.time_col is None and cst.TIME_COL in self.train_df:
              self.time_col = cst.TIME_COL
          if self.time_col is None:
              raise UncertaintyError(
                  "Time column must be provided when `x_mat` is not given. "
                  "It is used to generate necessary features for the uncertainty model."
              )
  
      if self.coverage is None:
          self.coverage = self.DEFAULT_COVERAGE
      # If ``self.coverage`` is given and ``quantiles`` is not given in ``params``,
      # the coverage is used to calculate quantiles.
      uncertainty_dict = get_silverkite_uncertainty_dict(
          uncertainty=self.uncertainty_dict, coverage=self.coverage
      )
      self.quantiles = uncertainty_dict["params"]["quantiles"]
  
imports: from __future__ import annotations
  from typing import Dict
  from typing import List
  from typing import Optional
  import pandas
  from sklearn.exceptions import NotFittedError
  from greykite.algo.common.l1_quantile_regression import QuantileRegression
  from greykite.algo.forecast.silverkite.forecast_silverkite import SilverkiteForecast
  from greykite.algo.forecast.silverkite.forecast_silverkite_helper import get_fourier_feature_col_names
  from greykite.algo.forecast.silverkite.forecast_silverkite_helper import get_silverkite_uncertainty_dict
  from greykite.common import constants
  from greykite.common.features.timeseries_features import fourier_series_multi_fcn
  from greykite.common.features.timeseries_features import get_default_origin_for_time_vars
  from greykite.sklearn.uncertainty.base_uncertainty_model import BaseUncertaintyModel
  from greykite.sklearn.uncertainty.exceptions import UncertaintyError
label_desc: Use image node_id 2 for calling the QuantileRegressionUncertaintyModel obj's underlying member method code with example usage: obj._check_input() without return types