class_docstr: Empirical and conformal prediction intervals.
  
  Implements empirical and conformal prediction intervals, on absolute residuals.
  Empirical prediction intervals are based on sliding window empirical quantiles.
  Conformal prediction intervals are implemented as described in [1]_.
  
  All intervals wrap an arbitrary forecaster, i.e., add probabilistic prediction
  capability to a given point prediction forecaster (first argument).
  
  method="conformal_bonferroni" is the method described in [1]_,
      where an arbitrary forecaster is used instead of the RNN.
  method="conformal" is the method in [1]_, but without Bonferroni correction.
      i.e., separate forecasts are made which results in H=1 (at all horizons).
  method="empirical" uses quantiles of relative signed residuals on training set,
      i.e., y_t+h^(i) - y-hat_t+h^(i), ranging over i, in the notation of [1]_,
      at quantiles 0.5-0.5*coverage (lower) and 0.5+0.5*coverage (upper),
      as offsets to the point prediction at forecast horizon h
  method="empirical_residual" uses empirical quantiles of absolute residuals
      on the training set, i.e., quantiles of epsilon-h (in notation [1]_),
      at quantile point (1-coverage)/2 quantiles, as offsets to point prediction
  
  Parameters
  ----------
  forecaster : estimator
      Estimator to which probabilistic forecasts are being added
  method : str, optional, default="empirical"
      "empirical": predictive interval bounds are empirical quantiles from training
      "empirical_residual": upper/lower are plusminus (1-coverage)/2 quantiles
          of the absolute residuals at horizon, i.e., of epsilon-h
      "conformal_bonferroni": Bonferroni, as in Stankeviciute et al
          Caveat: this does not give frequentist but conformal predictive intervals
      "conformal": as in Stankeviciute et al, but with H=1,
          i.e., no Bonferroni correction under number of indices in the horizon
  initial_window : float, int or None, optional (default=max(10, 0.1*len(y)))
      Defines the size of the initial training window
      If float, should be between 0.0 and 1.0 and represent the proportion
      of the dataset to include for the initial window for the train split.
      If int, represents the relative number of train samples in the initial window.
      If None, the value is set to the larger of 0.1*len(y) and 10
  sample_frac : float, optional, default=None
      value in range (0,1) corresponding to fraction of y index to calculate
      residuals matrix values for (for speeding up calculation)
  verbose : bool, optional, default=False
      whether to print warnings if windows with too few data points occur
  n_jobs : int or None, optional, default=1
      The number of jobs to run in parallel for fit.
      -1 means using all processors.
  
  References
  ----------
  .. [1] Kamile Stankeviciute, Ahmed M Alaa and Mihaela van der Schaar.
      Conformal Time Series Forecasting. NeurIPS 2021.
  
  Examples
  --------
  >>> from sktime.datasets import load_airline  # doctest: +SKIP
  >>> from sktime.forecasting.conformal import ConformalIntervals  # doctest: +SKIP
  >>> from sktime.forecasting.naive import NaiveForecaster  # doctest: +SKIP
  >>> y = load_airline()  # doctest: +SKIP
  >>> forecaster = NaiveForecaster(strategy="drift")  # doctest: +SKIP
  >>> conformal_forecaster = ConformalIntervals(forecaster)  # doctest: +SKIP
  >>> conformal_forecaster.fit(y, fh=[1, 2, 3])  # doctest: +SKIP
  ConformalIntervals(...)
  >>> pred_int = conformal_forecaster.predict_interval()  # doctest: +SKIP
  
  recommended use of ConformalIntervals together with ForecastingGridSearch
  is by 1. first running grid search, 2. then ConformalIntervals on the tuned params
  otherwise, nested sliding windows will cause high compute requirement
  
  >>> from sktime.datasets import load_airline
  >>> from sktime.forecasting.conformal import ConformalIntervals
  >>> from sktime.forecasting.naive import NaiveForecaster
  >>> from sktime.forecasting.model_selection import ForecastingGridSearchCV
  >>> from sktime.split import ExpandingWindowSplitter
  >>> from sktime.param_est.plugin import PluginParamsForecaster
  >>> # part 1 = grid search
  >>> cv = ExpandingWindowSplitter(fh=[1, 2, 3])  # doctest: +SKIP
  >>> forecaster = NaiveForecaster()  # doctest: +SKIP
  >>> param_grid = {"strategy" : ["last", "mean", "drift"]}  # doctest: +SKIP
  >>> gscv = ForecastingGridSearchCV(
  ...     forecaster=forecaster,
  ...     param_grid=param_grid,
  ...     cv=cv,
  ... )  # doctest: +SKIP
  >>> # part 2 = plug in results of grid search into conformal intervals estimator
  >>> conformal_with_fallback = ConformalIntervals(NaiveForecaster())
  >>> gscv_with_conformal = PluginParamsForecaster(
  ...     gscv,
  ...     conformal_with_fallback,
  ...     params={"forecaster": "best_forecaster"},
  ... )  # doctest: +SKIP
  >>> y = load_airline()  # doctest: +SKIP
  >>> gscv_with_conformal.fit(y, fh=[1, 2, 3])  # doctest: +SKIP
  PluginParamsForecaster(...)
  >>> y_pred_quantiles = gscv_with_conformal.predict_quantiles()  # doctest: +SKIP
class_docstr_tok: ["Empirical","and","conformal","prediction","intervals",".","Implements","empirical","and","conformal","prediction","intervals",",","on","absolute","residuals",".","Empirical","prediction","intervals","are","based","on","sliding","window","empirical","quantiles",".","Conformal","prediction","intervals","are","implemented","as","described","in","[","1","]","_",".","All","intervals","wrap","an","arbitrary","forecaster",",","i.e.",",","add","probabilistic","prediction","capability","to","a","given","point","prediction","forecaster","(","first","argument",")",".","method=","''","conformal_bonferroni","''","is","the","method","described","in","[","1","]","_",",","where","an","arbitrary","forecaster","is","used","instead","of","the","RNN",".","method=","''","conformal","''","is","the","method","in","[","1","]","_",",","but","without","Bonferroni","correction",".","i.e.",",","separate","forecasts","are","made","which","results","in","H=1","(","at","all","horizons",")",".","method=","''","empirical","''","uses","quantiles","of","relative","signed","residuals","on","training","set",",","i.e.",",","y_t+h^","(","i",")","-","y-hat_t+h^","(","i",")",",","ranging","over","i",",","in","the","notation","of","[","1","]","_",",","at","quantiles","0.5-0.5","*","coverage","(","lower",")","and","0.5+0.5","*","coverage","(","upper",")",",","as","offsets","to","the","point","prediction","at","forecast","horizon","h","method=","''","empirical_residual","''","uses","empirical","quantiles","of","absolute","residuals","on","the","training","set",",","i.e.",",","quantiles","of","epsilon-h","(","in","notation","[","1","]","_",")",",","at","quantile","point","(","1-coverage",")","\/2","quantiles",",","as","offsets","to","point","prediction","Parameters","--","--","--","--","--","forecaster",":","estimator","Estimator","to","which","probabilistic","forecasts","are","being","added","method",":","str",",","optional",",","default=","''","empirical","''","``","empirical","''",":","predictive","interval","bounds","are","empirical","quantiles","from","training","``","empirical_residual","''",":","upper\/lower","are","plusminus","(","1-coverage",")","\/2","quantiles","of","the","absolute","residuals","at","horizon",",","i.e.",",","of","epsilon-h","``","conformal_bonferroni","''",":","Bonferroni",",","as","in","Stankeviciute","et","al","Caveat",":","this","does","not","give","frequentist","but","conformal","predictive","intervals","``","conformal","''",":","as","in","Stankeviciute","et","al",",","but","with","H=1",",","i.e.",",","no","Bonferroni","correction","under","number","of","indices","in","the","horizon","initial_window",":","float",",","int","or","None",",","optional","(","default=max","(","10",",","0.1","*","len","(","y",")",")",")","Defines","the","size","of","the","initial","training","window","If","float",",","should","be","between","0.0","and","1.0","and","represent","the","proportion","of","the","dataset","to","include","for","the","initial","window","for","the","train","split",".","If","int",",","represents","the","relative","number","of","train","samples","in","the","initial","window",".","If","None",",","the","value","is","set","to","the","larger","of","0.1","*","len","(","y",")","and","10","sample_frac",":","float",",","optional",",","default=None","value","in","range","(","0,1",")","corresponding","to","fraction","of","y","index","to","calculate","residuals","matrix","values","for","(","for","speeding","up","calculation",")","verbose",":","bool",",","optional",",","default=False","whether","to","print","warnings","if","windows","with","too","few","data","points","occur","n_jobs",":","int","or","None",",","optional",",","default=1","The","number","of","jobs","to","run","in","parallel","for","fit",".","-1","means","using","all","processors",".","References","--","--","--","--","--","..","[","1","]","Kamile","Stankeviciute",",","Ahmed","M","Alaa","and","Mihaela","van","der","Schaar",".","Conformal","Time","Series","Forecasting",".","NeurIPS","2021",".","Examples","--","--","--","--",">",">",">","from","sktime.datasets","import","load_airline","#","doctest",":","+SKIP",">",">",">","from","sktime.forecasting.conformal","import","ConformalIntervals","#","doctest",":","+SKIP",">",">",">","from","sktime.forecasting.naive","import","NaiveForecaster","#","doctest",":","+SKIP",">",">",">","y","=","load_airline","(",")","#","doctest",":","+SKIP",">",">",">","forecaster","=","NaiveForecaster","(","strategy=","''","drift","''",")","#","doctest",":","+SKIP",">",">",">","conformal_forecaster","=","ConformalIntervals","(","forecaster",")","#","doctest",":","+SKIP",">",">",">","conformal_forecaster.fit","(","y",",","fh=","[","1",",","2",",","3","]",")","#","doctest",":","+SKIP","ConformalIntervals","(","...",")",">",">",">","pred_int","=","conformal_forecaster.predict_interval","(",")","#","doctest",":","+SKIP","recommended","use","of","ConformalIntervals","together","with","ForecastingGridSearch","is","by","1.","first","running","grid","search",",","2.","then","ConformalIntervals","on","the","tuned","params","otherwise",",","nested","sliding","windows","will","cause","high","compute","requirement",">",">",">","from","sktime.datasets","import","load_airline",">",">",">","from","sktime.forecasting.conformal","import","ConformalIntervals",">",">",">","from","sktime.forecasting.naive","import","NaiveForecaster",">",">",">","from","sktime.forecasting.model_selection","import","ForecastingGridSearchCV",">",">",">","from","sktime.split","import","ExpandingWindowSplitter",">",">",">","from","sktime.param_est.plugin","import","PluginParamsForecaster",">",">",">","#","part","1","=","grid","search",">",">",">","cv","=","ExpandingWindowSplitter","(","fh=","[","1",",","2",",","3","]",")","#","doctest",":","+SKIP",">",">",">","forecaster","=","NaiveForecaster","(",")","#","doctest",":","+SKIP",">",">",">","param_grid","=","{","``","strategy","''",":","[","``","last","''",",","``","mean","''",",","``","drift","''","]","}","#","doctest",":","+SKIP",">",">",">","gscv","=","ForecastingGridSearchCV","(","...","forecaster=forecaster",",","...","param_grid=param_grid",",","...","cv=cv",",","...",")","#","doctest",":","+SKIP",">",">",">","#","part","2","=","plug","in","results","of","grid","search","into","conformal","intervals","estimator",">",">",">","conformal_with_fallback","=","ConformalIntervals","(","NaiveForecaster","(",")",")",">",">",">","gscv_with_conformal","=","PluginParamsForecaster","(","...","gscv",",","...","conformal_with_fallback",",","...","params=","{","``","forecaster","''",":","``","best_forecaster","''","}",",","...",")","#","doctest",":","+SKIP",">",">",">","y","=","load_airline","(",")","#","doctest",":","+SKIP",">",">",">","gscv_with_conformal.fit","(","y",",","fh=","[","1",",","2",",","3","]",")","#","doctest",":","+SKIP","PluginParamsForecaster","(","...",")",">",">",">","y_pred_quantiles","=","gscv_with_conformal.predict_quantiles","(",")","#","doctest",":","+SKIP"]
code: def __init__(
      self,
      forecaster,
      method="empirical",
      initial_window=None,
      sample_frac=None,
      verbose=False,
      n_jobs=None,
  ):
      if not isinstance(method, str):
          raise TypeError(
              f"method must be a str, one of {self.ALLOWED_METHODS}"
          )
  
      if method not in self.ALLOWED_METHODS:
          raise ValueError(
              f"method must be one of {self.ALLOWED_METHODS}, but found {method}"
          )
  
      self.forecaster = forecaster
      self.method = method
      self.verbose = verbose
      self.initial_window = initial_window
      self.sample_frac = sample_frac
      self.n_jobs = n_jobs
      self.forecasters_ = []
  
      super().__init__()
  
      tags_to_clone = [
          "requires-fh-in-fit",
          "ignores-exogeneous-X",
          "handles-missing-data",
          "X-y-must-have-same-index",
          "enforce_index_type",
      ]
      self.clone_tags(self.forecaster, tags_to_clone)
  
file_path: sktime/sktime/forecasting/conformal.py
imports: from math import floor
  import numpy
  import pandas
  from joblib import Parallel, delayed
  from sklearn.base import clone
  from sktime.datatypes import MTYPE_LIST_SERIES, convert, convert_to
  from sktime.datatypes._utilities import get_slice
  from sktime.forecasting.base import BaseForecaster
  from sktime.utils.warnings import warn
label_desc: Use image node_id 1 to create a new ConformalIntervals object from inherited base classes: BaseForecaster with example: obj = ConformalIntervals(forecaster, method, initial_window, sample_frac, verbose, n_jobs)