class_docstr: Conformal prediction dataclass
  
  Parameters
  ----------
  alpha : float or tuple
      user-specified significance level of the prediction interval, float if coverage error spread arbitrarily over
      left and right tails, tuple of two floats for different coverage error over left and right tails respectively
  method : str
      name of conformal prediction technique used
  
      Options
          * ``naive``: Naive or Absolute Residual
          * ``cqr``: Conformalized Quantile Regression
  n_forecasts : int
      optional, number of steps ahead of prediction time step to forecast
  quantiles : list
      optional, list of quantiles for quantile regression uncertainty estimate
class_docstr_tok: ["Conformal","prediction","dataclass","Parameters","--","--","--","--","--","alpha",":","float","or","tuple","user-specified","significance","level","of","the","prediction","interval",",","float","if","coverage","error","spread","arbitrarily","over","left","and","right","tails",",","tuple","of","two","floats","for","different","coverage","error","over","left","and","right","tails","respectively","method",":","str","name","of","conformal","prediction","technique","used","Options","*","``","naive","``",":","Naive","or","Absolute","Residual","*","``","cqr","``",":","Conformalized","Quantile","Regression","n_forecasts",":","int","optional",",","number","of","steps","ahead","of","prediction","time","step","to","forecast","quantiles",":","list","optional",",","list","of","quantiles","for","quantile","regression","uncertainty","estimate"]
docstr: Apply a given conformal prediction technique to get the uncertainty prediction intervals (or q-hat) for test
  dataframe.
  
  Parameters
  ----------
      df : pd.DataFrame
          test dataframe
      df_cal : pd.DataFrame
          calibration dataframe
      show_all_PI : bool
          whether to return all prediction intervals (including quantile regression and conformal prediction)
  
      Returns
      -------
          pd.DataFrame
              test dataframe with uncertainty prediction intervals
docstr_tok: ["Apply","a","given","conformal","prediction","technique","to","get","the","uncertainty","prediction","intervals","(","or","q-hat",")","for","test","dataframe",".","Parameters","--","--","--","--","--","df",":","pd.DataFrame","test","dataframe","df_cal",":","pd.DataFrame","calibration","dataframe","show_all_PI",":","bool","whether","to","return","all","prediction","intervals","(","including","quantile","regression","and","conformal","prediction",")","Returns","--","--","--","-","pd.DataFrame","test","dataframe","with","uncertainty","prediction","intervals"]
code: def predict(
      self,
      df: pd.DataFrame,
      df_cal: pd.DataFrame,
      show_all_PI: bool = False,
  ) -> pd.DataFrame:
      """Apply a given conformal prediction technique to get the uncertainty prediction intervals (or q-hat) for test
      dataframe.
  
      Parameters
      ----------
          df : pd.DataFrame
              test dataframe
          df_cal : pd.DataFrame
              calibration dataframe
          show_all_PI : bool
              whether to return all prediction intervals (including quantile regression and conformal prediction)
  
          Returns
          -------
              pd.DataFrame
                  test dataframe with uncertainty prediction intervals
  
      """
      df_qr = df.copy()
  
      for step_number in range(1, self.n_forecasts + 1):
          # conformalize
          noncon_scores = self._get_nonconformity_scores(
              df_cal, step_number
          )
          q_hat = self._get_q_hat(df_cal, noncon_scores)
          y_hat_col = f"yhat{step_number}"
          y_hat_lo_col = f"{y_hat_col} {min(self.quantiles) * 100}%"
          y_hat_hi_col = f"{y_hat_col} {max(self.quantiles) * 100}%"
          if self.method == "naive" and self.symmetrical:
              q_hat_sym = q_hat["q_hat_sym"]
              df[y_hat_lo_col] = df[y_hat_col] - q_hat_sym
              df[y_hat_hi_col] = df[y_hat_col] + q_hat_sym
          elif self.method == "cqr" and self.symmetrical:
              q_hat_sym = q_hat["q_hat_sym"]
              df[y_hat_lo_col] = df[y_hat_lo_col] - q_hat_sym
              df[y_hat_hi_col] = df[y_hat_hi_col] + q_hat_sym
          elif self.method == "cqr" and not self.symmetrical:
              q_hat_lo = q_hat["q_hat_lo"]
              q_hat_hi = q_hat["q_hat_hi"]
              df[y_hat_lo_col] = df[y_hat_lo_col] - q_hat_lo
              df[y_hat_hi_col] = df[y_hat_hi_col] + q_hat_hi
          else:
              raise ValueError(
                  f"Unknown conformal prediction method '{self.method}'. Please input either 'naive' or 'cqr'."
              )
          if step_number == 1:
              # save nonconformity scores of the first timestep
              self.noncon_scores = noncon_scores
  
          # append the dictionary of q_hats to the dataframe based on the keys of the dictionary
          q_hat_df = pd.DataFrame([q_hat])
          self.q_hats = pd.concat(
              [self.q_hats, q_hat_df], ignore_index=True
          )
  
          # if show_all_PI is True, add the quantile regression prediction intervals
          if show_all_PI:
              df_quantiles = [
                  col
                  for col in df_qr.columns
                  if "%" in col and f"yhat{step_number}" in col
              ]
              df_add = df_qr[df_quantiles]
  
              if self.method == "naive":
                  cp_lo_col = f"yhat{step_number} - qhat{step_number}"  # e.g. yhat1 - qhat1
                  cp_hi_col = f"yhat{step_number} + qhat{step_number}"  # e.g. yhat1 + qhat1
                  df.rename(
                      columns={
                          y_hat_lo_col: cp_lo_col,
                          y_hat_hi_col: cp_hi_col,
                      },
                      inplace=True,
                  )
              elif self.method == "cqr":
                  qr_lo_col = f"yhat{step_number} {max(self.quantiles) * 100}% - qhat{step_number}"  # e.g. yhat1 95% - qhat1
                  qr_hi_col = f"yhat{step_number} {min(self.quantiles) * 100}% + qhat{step_number}"  # e.g. yhat1 5% + qhat1
                  df.rename(
                      columns={
                          y_hat_lo_col: qr_lo_col,
                          y_hat_hi_col: qr_hi_col,
                      },
                      inplace=True,
                  )
  
              df = pd.concat([df, df_add], axis=1, ignore_index=False)
  
      return df
  
file_path: neural_prophet/neuralprophet/uncertainty.py
imports: import re
  from dataclasses import dataclass
  from typing import Any, List, Tuple, Union
  import matplotlib
  import numpy
  import pandas
  from neuralprophet.plot_forecast_matplotlib import plot_interval_width_per_timestep, plot_nonconformity_scores
  from neuralprophet.plot_forecast_plotly import plot_interval_width_per_timestep
  from neuralprophet.plot_forecast_plotly import plot_nonconformity_scores
  from neuralprophet.plot_utils import log_warning_deprecation_plotly, select_plotting_backend
label_desc: Use image node_id 2 for calling the Conformal obj's underlying member method code with example usage: obj.predict(df, df_cal, show_all_PI) and returns: df