class_docstr: Compute the prediction variance based on a naive strategy.
  
  NaiveVariance adds to a `forecaster` the ability to compute the
  prediction variance based on naive assumptions about the time series.
  The simple strategy is as follows:
  - Let :math:`y_1,\dots,y_T` be the time series we fit the estimator :math:`f` to.
  - Let :math:`\widehat{y}_{ij}` be the forecast for time point :math:`j`, obtained
  from fitting the forecaster to the partial time series :math:`y_1,\dots,y_i`.
  - We compute the residuals matrix :math:`R=(r_{ij})=(y_j-\widehat{y}_{ij})`.
  - The variance prediction :math:`v_k` for :math:`y_{T+k}` is
  :math:`\frac{1}{T-k}\sum_{i=1}^{T-k} a_{i,i+k}^2`
  because we are averaging squared residuals of all forecasts that are :math:`k`
  time points ahead.
  - And for the covariance matrix prediction, the formula becomes
  :math:`Cov(y_k, y_l)=\frac{\sum_{i=1}^N \hat{r}_{k,k+i}*\hat{r}_{l,l+i}}{N}`.
  
  The resulting forecaster will implement
      `predict_interval`, `predict_quantiles`, `predict_var`, and `predict_proba`,
      even if the wrapped forecaster `forecaster` did not have this capability;
      for point forecasts (`predict`), behaves like the wrapped forecaster.
  
  Parameters
  ----------
  forecaster : estimator
      Estimator to which probabilistic forecasts are being added
  initial_window : int, optional, default=1
      number of minimum initial indices to use for fitting when computing residuals
  verbose : bool, optional, default=False
      whether to print warnings if windows with too few data points occur
  
  Examples
  --------
  >>> from sktime.datasets import load_airline
  >>> from sktime.forecasting.naive import NaiveForecaster, NaiveVariance
  >>> y = load_airline()
  >>> forecaster = NaiveForecaster(strategy="drift")
  >>> variance_forecaster = NaiveVariance(forecaster)
  >>> variance_forecaster.fit(y)
  NaiveVariance(...)
  >>> var_pred = variance_forecaster.predict_var(fh=[1,2,3])
class_docstr_tok: ["Compute","the","prediction","variance","based","on","a","naive","strategy",".","NaiveVariance","adds","to","a","`","forecaster","`","the","ability","to","compute","the","prediction","variance","based","on","naive","assumptions","about","the","time","series",".","The","simple","strategy","is","as","follows",":","-","Let",":","math",":","`","y_1",",","\\dots",",","y_T","`","be","the","time","series","we","fit","the","estimator",":","math",":","`","f","`","to",".","-","Let",":","math",":","`","\\widehat","{","y","}","_","{","ij","}","`","be","the","forecast","for","time","point",":","math",":","`","j","`",",","obtained","from","fitting","the","forecaster","to","the","partial","time","series",":","math",":","`","y_1",",","\\dots",",","y_i","`",".","-","We","compute","the","residuals","matrix",":","math",":","`","R=","(","r_","{","ij","}",")","=","(","y_j-\\widehat","{","y","}","_","{","ij","}",")","`",".","-","The","variance","prediction",":","math",":","`","v_k","`","for",":","math",":","`","y_","{","T+k","}","`","is",":","math",":","`","\\frac","{","1","}","{","T-k","}","\\sum_","{","i=1","}","^","{","T-k","}","a_","{","i",",","i+k","}","^2","`","because","we","are","averaging","squared","residuals","of","all","forecasts","that","are",":","math",":","`","k","`","time","points","ahead",".","-","And","for","the","covariance","matrix","prediction",",","the","formula","becomes",":","math",":","`","Cov","(","y_k",",","y_l",")","=\\frac","{","\\sum_","{","i=1","}","^N","\\hat","{","r","}","_","{","k",",","k+i","}","*","\\hat","{","r","}","_","{","l",",","l+i","}","}","{","N","}","`",".","The","resulting","forecaster","will","implement","`","predict_interval","`",",","`","predict_quantiles","`",",","`","predict_var","`",",","and","`","predict_proba","`",",","even","if","the","wrapped","forecaster","`","forecaster","`","did","not","have","this","capability",";","for","point","forecasts","(","`","predict","`",")",",","behaves","like","the","wrapped","forecaster",".","Parameters","--","--","--","--","--","forecaster",":","estimator","Estimator","to","which","probabilistic","forecasts","are","being","added","initial_window",":","int",",","optional",",","default=1","number","of","minimum","initial","indices","to","use","for","fitting","when","computing","residuals","verbose",":","bool",",","optional",",","default=False","whether","to","print","warnings","if","windows","with","too","few","data","points","occur","Examples","--","--","--","--",">",">",">","from","sktime.datasets","import","load_airline",">",">",">","from","sktime.forecasting.naive","import","NaiveForecaster",",","NaiveVariance",">",">",">","y","=","load_airline","(",")",">",">",">","forecaster","=","NaiveForecaster","(","strategy=","''","drift","''",")",">",">",">","variance_forecaster","=","NaiveVariance","(","forecaster",")",">",">",">","variance_forecaster.fit","(","y",")","NaiveVariance","(","...",")",">",">",">","var_pred","=","variance_forecaster.predict_var","(","fh=","[","1,2,3","]",")"]
code: def _fit(self, y, X, fh):
      self.fh_early_ = fh is not None
      self.forecaster_ = self.forecaster.clone()
      self.forecaster_.fit(y=y, X=X, fh=fh)
  
      if self.fh_early_:
          self.residuals_matrix_ = self._compute_sliding_residuals(
              y=y,
              X=X,
              forecaster=self.forecaster,
              initial_window=self.initial_window,
          )
  
      return self
  
imports: import math
  import numpy
  import pandas
  from scipy.stats import norm
  from sktime.datatypes._convert import convert, convert_to
  from sktime.datatypes._utilities import get_slice
  from sktime.forecasting.base import ForecastingHorizon
  from sktime.forecasting.base._base import DEFAULT_ALPHA, BaseForecaster
  from sktime.forecasting.base._sktime import _BaseWindowForecaster
  from sktime.utils.seasonality import _pivot_sp, _unpivot_sp
  from sktime.utils.validation import check_window_length
  from sktime.utils.validation.forecasting import check_sp
  from sktime.utils.warnings import warn
label_desc: Use image node_id 2 for calling the NaiveVariance obj's underlying member method code with example usage: obj._fit(y, X, fh) and returns: self