class_docstr: Implements STLForecaster based on statsmodels.tsa.seasonal.STL implementation.
  
  The STLForecaster applies the following algorithm, also see [1]_.
  
  In `fit`:
  
  1. Use `statsmodels` `STL` [2]_ to decompose the given series `y` into
     the three components: `trend`, `season` and `residuals`.
  2. Fit clones of `forecaster_trend` to `trend`, `forecaster_seasonal` to `season`,
     and `forecaster_resid` to `residuals`, using `y`, `X`, `fh` from `fit`.
     The forecasters are fitted as clones, stored in the attributes
     `forecaster_trend_`, `forecaster_seasonal_`, `forecaster_resid_`.
  
  In `predict`, forecasts as follows:
  
  1. Obtain forecasts `y_pred_trend` from `forecaster_trend_`,
     `y_pred_seasonal` from `forecaster_seasonal_`, and
     `y_pred_residual` from `forecaster_resid_`, using `X`, `fh`, from `predict`.
  2. Recompose `y_pred` as `y_pred = y_pred_trend + y_pred_seasonal + y_pred_residual`
  3. Return `y_pred`
  
      `update` refits entirely, i.e., behaves as `fit` on all data seen so far.
  
  Parameters
  ----------
  sp : int, optional, default=2. Passed to `statsmodels` `STL`.
      Length of the seasonal period passed to `statsmodels` `STL`.
      (forecaster_seasonal, forecaster_resid) that are None. The
      default forecaster_trend does not get sp as trend is independent
      to seasonality.
  seasonal : int, optional., default=7. Passed to `statsmodels` `STL`.
      Length of the seasonal smoother. Must be an odd integer >=3, and should
      normally be >= 7 (default).
  trend : {int, None}, optional, default=None. Passed to `statsmodels` `STL`.
      Length of the trend smoother. Must be an odd integer. If not provided
      uses the smallest odd integer greater than
      1.5 * period / (1 - 1.5 / seasonal), following the suggestion in
      the original implementation.
  low_pass : {int, None}, optional, default=None. Passed to `statsmodels` `STL`.
      Length of the low-pass filter. Must be an odd integer >=3. If not
      provided, uses the smallest odd integer > period.
  seasonal_deg : int, optional, default=1. Passed to `statsmodels` `STL`.
      Degree of seasonal LOESS. 0 (constant) or 1 (constant and trend).
  trend_deg : int, optional, default=1. Passed to `statsmodels` `STL`.
      Degree of trend LOESS. 0 (constant) or 1 (constant and trend).
  low_pass_deg : int, optional, default=1. Passed to `statsmodels` `STL`.
      Degree of low pass LOESS. 0 (constant) or 1 (constant and trend).
  robust : bool, optional, default=False. Passed to `statsmodels` `STL`.
      Flag indicating whether to use a weighted version that is robust to
      some forms of outliers.
  seasonal_jump : int, optional, default=1. Passed to `statsmodels` `STL`.
      Positive integer determining the linear interpolation step. If larger
      than 1, the LOESS is used every seasonal_jump points and linear
      interpolation is between fitted points. Higher values reduce
      estimation time.
  trend_jump : int, optional, default=1. Passed to `statsmodels` `STL`.
      Positive integer determining the linear interpolation step. If larger
      than 1, the LOESS is used every trend_jump points and values between
      the two are linearly interpolated. Higher values reduce estimation
      time.
  low_pass_jump : int, optional, default=1. Passed to `statsmodels` `STL`.
      Positive integer determining the linear interpolation step. If larger
      than 1, the LOESS is used every low_pass_jump points and values between
      the two are linearly interpolated. Higher values reduce estimation
      time.
  inner_iter: int or None, optional, default=None. Passed to `statsmodels` `STL`.
      Number of iterations to perform in the inner loop. If not provided uses 2 if
      robust is True, or 5 if not. This param goes into STL.fit() from statsmodels.
  outer_iter: int or None, optional, default=None. Passed to `statsmodels` `STL`.
      Number of iterations to perform in the outer loop. If not provided uses 15 if
      robust is True, or 0 if not. This param goes into STL.fit() from statsmodels.
  forecaster_trend : sktime forecaster, optional
      Forecaster to be fitted on trend_ component of the
      STL, by default None. If None, then
      a NaiveForecaster(strategy="drift") is used.
  forecaster_seasonal : sktime forecaster, optional
      Forecaster to be fitted on seasonal_ component of the
      STL, by default None. If None, then
      a NaiveForecaster(strategy="last") is used.
  forecaster_resid : sktime forecaster, optional
      Forecaster to be fitted on resid_ component of the
      STL, by default None. If None, then
      a NaiveForecaster(strategy="mean") is used.
  
  Attributes
  ----------
  trend_ : pd.Series
      Trend component.
  seasonal_ : pd.Series
      Seasonal component.
  resid_ : pd.Series
      Residuals component.
  forecaster_trend_ : sktime forecaster
      Fitted trend forecaster.
  forecaster_seasonal_ : sktime forecaster
      Fitted seasonal forecaster.
  forecaster_resid_ : sktime forecaster
      Fitted residual forecaster.
  
  Examples
  --------
  >>> from sktime.datasets import load_airline
  >>> from sktime.forecasting.trend import STLForecaster
  >>> y = load_airline()
  >>> forecaster = STLForecaster(sp=12)  # doctest: +SKIP
  >>> forecaster.fit(y)  # doctest: +SKIP
  STLForecaster(...)
  >>> y_pred = forecaster.predict(fh=[1,2,3])  # doctest: +SKIP
  
  See Also
  --------
  Deseasonalizer
  Detrender
  
  References
  ----------
  .. [1] R. B. Cleveland, W. S. Cleveland, J.E. McRae, and I. Terpenning (1990)
     STL: A Seasonal-Trend Decomposition Procedure Based on LOESS.
     Journal of Official Statistics, 6, 3-73.
  .. [2] https://www.statsmodels.org/dev/generated/statsmodels.tsa.seasonal.STL.html
docstr: Fit forecaster to training data.
  
  Parameters
  ----------
  y : pd.Series
      Target time series to which to fit the forecaster.
  fh : int, list, np.array or ForecastingHorizon, optional (default=None)
      The forecasters horizon with the steps ahead to to predict.
  X : pd.DataFrame, optional (default=None)
  
  Returns
  -------
  self : returns an instance of self.
docstr_tok: ["Fit","forecaster","to","training","data",".","Parameters","--","--","--","--","--","y",":","pd.Series","Target","time","series","to","which","to","fit","the","forecaster",".","fh",":","int",",","list",",","np.array","or","ForecastingHorizon",",","optional","(","default=None",")","The","forecasters","horizon","with","the","steps","ahead","to","to","predict",".","X",":","pd.DataFrame",",","optional","(","default=None",")","Returns","--","--","--","-","self",":","returns","an","instance","of","self","."]
code: def _fit(self, y, X, fh):
      """Fit forecaster to training data.
  
      Parameters
      ----------
      y : pd.Series
          Target time series to which to fit the forecaster.
      fh : int, list, np.array or ForecastingHorizon, optional (default=None)
          The forecasters horizon with the steps ahead to to predict.
      X : pd.DataFrame, optional (default=None)
  
      Returns
      -------
      self : returns an instance of self.
      """
      from statsmodels.tsa.seasonal import STL as _STL
  
      from sktime.forecasting.naive import NaiveForecaster
  
      self._stl = _STL(
          y.values,
          period=self.sp,
          seasonal=self.seasonal,
          trend=self.trend,
          low_pass=self.low_pass,
          seasonal_deg=self.seasonal_deg,
          trend_deg=self.trend_deg,
          low_pass_deg=self.low_pass_deg,
          robust=self.robust,
          seasonal_jump=self.seasonal_jump,
          trend_jump=self.trend_jump,
          low_pass_jump=self.low_pass_jump,
      ).fit(inner_iter=self.inner_iter, outer_iter=self.outer_iter)
  
      self.seasonal_ = pd.Series(self._stl.seasonal, index=y.index)
      self.resid_ = pd.Series(self._stl.resid, index=y.index)
      self.trend_ = pd.Series(self._stl.trend, index=y.index)
  
      self.forecaster_seasonal_ = (
          NaiveForecaster(sp=self.sp, strategy="last")
          if self.forecaster_seasonal is None
          else self.forecaster_seasonal.clone()
      )
      # trend forecaster does not need sp
      self.forecaster_trend_ = (
          NaiveForecaster(strategy="drift")
          if self.forecaster_trend is None
          else self.forecaster_trend.clone()
      )
      self.forecaster_resid_ = (
          NaiveForecaster(sp=self.sp, strategy="mean")
          if self.forecaster_resid is None
          else self.forecaster_resid.clone()
      )
  
      # fitting forecasters to different components
      self.forecaster_seasonal_.fit(y=self.seasonal_, X=X, fh=fh)
      self.forecaster_trend_.fit(y=self.trend_, X=X, fh=fh)
      self.forecaster_resid_.fit(y=self.resid_, X=X, fh=fh)
  
file_path: sktime/sktime/forecasting/trend/_stl_forecaster.py
imports: import pandas
  from sktime.forecasting.base import BaseForecaster
label_desc: Use image node_id 2 for calling the STLForecaster obj's underlying member method code with example usage: obj._fit(y, X, fh) without return types