class_docstr: This class turns any regressor compatible with the scikit-learn API into a
  recursive (multi-step) forecaster with a custom function to create predictors.
  
  Parameters
  ----------
  regressor : regressor or pipeline compatible with the scikit-learn API
      An instance of a regressor or pipeline compatible with the scikit-learn API.
  fun_predictors : Callable
      Function that receives a time series as input (numpy ndarray) and returns 
      another numpy ndarray with the predictors.
  window_size : int
      Size of the window needed by `fun_predictors` to create the predictors.
  name_predictors : list, default `None`
      Name of the predictors returned by `fun_predictors`. If `None`, predictors are
      named using the prefix 'custom_predictor_<i>' where `i` is the index of the position
      the predictor has in the returned array of `fun_predictors`.
  transformer_y : object transformer (preprocessor), default `None`
      An instance of a transformer (preprocessor) compatible with the scikit-learn
      preprocessing API with methods: fit, transform, fit_transform and inverse_transform.
      ColumnTransformers are not allowed since they do not have inverse_transform method.
      The transformation is applied to `y` before training the forecaster.
  transformer_exog : object transformer (preprocessor), default `None`
      An instance of a transformer (preprocessor) compatible with the scikit-learn
      preprocessing API. The transformation is applied to `exog` before training the
      forecaster. `inverse_transform` is not available when using ColumnTransformers.
  weight_func : Callable, default `None`
      Function that defines the individual weights for each sample based on the
      index. For example, a function that assigns a lower weight to certain dates.
      Ignored if `regressor` does not have the argument `sample_weight` in its `fit`
      method. The resulting `sample_weight` cannot have negative values.
  differentiation : int, default `None`
      Order of differencing applied to the time series before training the forecaster.
      If `None`, no differencing is applied. The order of differentiation is the number
      of times the differencing operation is applied to a time series. Differencing
      involves computing the differences between consecutive data points in the series.
      Diferentiarion is reversed in the output of `predict()` and `predict_interval()`.
      **WARNING: This argument is newly introduced and requires special attention. It
      is still experimental and may undergo changes.**
      **New in version 0.10.0**
  fit_kwargs : dict, default `None`
      Additional arguments to be passed to the `fit` method of the regressor.
  forecaster_id : str, int, default `None`
      Name used as an identifier of the forecaster.
  
  Attributes
  ----------
  regressor : regressor compatible with the scikit-learn API
      An instance of a regressor compatible with the scikit-learn API.
  fun_predictors : Callable
      Function that receives a time series as input (numpy ndarray) and returns
      another numpy ndarray with the predictors.
  source_code_fun_predictors : str
      Source code of the custom function used to create the predictors.
  window_size : int
      Size of the window needed by `fun_predictors` to create the predictors.
      If `differentiation` is not `None`, `window_size` is increased by the
      order of differentiation.
  name_predictors : list
      Name of the predictors returned by `fun_predictors`. If `None`, predictors are
      named using the prefix 'custom_predictor_<i>' where `i` is the index of the position
      the predictor has in the returned array of `fun_predictors`.
  transformer_y : object transformer (preprocessor)
      An instance of a transformer (preprocessor) compatible with the scikit-learn
      preprocessing API with methods: fit, transform, fit_transform and inverse_transform.
      ColumnTransformers are not allowed since they do not have inverse_transform method.
      The transformation is applied to `y` before training the forecaster.
  transformer_exog : object transformer (preprocessor)
      An instance of a transformer (preprocessor) compatible with the scikit-learn
      preprocessing API. The transformation is applied to `exog` before training the
      forecaster. `inverse_transform` is not available when using ColumnTransformers.
  weight_func : Callable
      Function that defines the individual weights for each sample based on the
      index. For example, a function that assigns a lower weight to certain dates.
      Ignored if `regressor` does not have the argument `sample_weight` in its `fit`
      method. The resulting `sample_weight` cannot have negative values.
  differentiation : int, default `None`
      Order of differencing applied to the time series before training the forecaster.
      If `None`, no differencing is applied. The order of differentiation is the number
      of times the differencing operation is applied to a time series. Differencing
      involves computing the differences between consecutive data points in the series.
      Differentiation is reversed in the output of `predict()` and `predict_interval()`.
      **WARNING: This argument is newly introduced and requires special attention. It
      is still experimental and may undergo changes.**
      **New in version 0.10.0**
  source_code_weight_func : str
      Source code of the custom function used to create weights.
  last_window : pandas Series
      This window represents the most recent data observed by the predictor
      during its training phase. It contains the values needed to predict the
      next step immediately after the training data. These values are stored
      in the original scale of the time series before undergoing any transformations
      or differentiation. When `differentiation` parameter is specified, the
      dimensions of the `last_window` are expanded as many values as the order
      of differentiation. For example, if `fun_predictors()` requires 7 lagged
      values and `differentiation=1`, `last_window` will contain 8 values.
  index_type : type
      Type of index of the input used in training.
  index_freq : str
      Frequency of Index of the input used in training.
  training_range : pandas Index
      First and last values of index of the data used during training.
  included_exog : bool
      If the forecaster has been trained using exogenous variable/s.
  exog_type : type
      Type of exogenous data (pandas Series or DataFrame) used in training.
  exog_dtypes : dict
      Type of each exogenous variable/s used in training. If `transformer_exog` 
      is used, the dtypes are calculated after the transformation.
  exog_col_names : list
      Names of columns of `exog` if `exog` used in training was a pandas
      DataFrame.
  X_train_col_names : list
      Names of columns of the matrix created internally for training.
  fit_kwargs : dict
      Additional arguments to be passed to the `fit` method of the regressor.
  in_sample_residuals : numpy ndarray
      Residuals of the model when predicting training data. Only stored up to
      1000 values. If `transformer_y` is not `None`, residuals are stored in the
      transformed scale.
  out_sample_residuals : numpy ndarray
      Residuals of the model when predicting non training data. Only stored
      up to 1000 values. If `transformer_y` is not `None`, residuals
      are assumed to be in the transformed scale. Use `set_out_sample_residuals` 
      method to set values.
  fitted : bool
      Tag to identify if the regressor has been fitted (trained).
  creation_date : str
      Date of creation.
  fit_date : str
      Date of last fit.
  skforecast_version : str
      Version of skforecast library used to create the forecaster.
  python_version : str
      Version of python used to create the forecaster.
  forecaster_id : str, int
      Name used as an identifier of the forecaster.
class_docstr_tok: ["This","class","turns","any","regressor","compatible","with","the","scikit-learn","API","into","a","recursive","(","multi-step",")","forecaster","with","a","custom","function","to","create","predictors",".","Parameters","--","--","--","--","--","regressor",":","regressor","or","pipeline","compatible","with","the","scikit-learn","API","An","instance","of","a","regressor","or","pipeline","compatible","with","the","scikit-learn","API",".","fun_predictors",":","Callable","Function","that","receives","a","time","series","as","input","(","numpy","ndarray",")","and","returns","another","numpy","ndarray","with","the","predictors",".","window_size",":","int","Size","of","the","window","needed","by","`","fun_predictors","`","to","create","the","predictors",".","name_predictors",":","list",",","default","`","None","`","Name","of","the","predictors","returned","by","`","fun_predictors","`",".","If","`","None","`",",","predictors","are","named","using","the","prefix","'custom_predictor_","<","i",">","'","where","`","i","`","is","the","index","of","the","position","the","predictor","has","in","the","returned","array","of","`","fun_predictors","`",".","transformer_y",":","object","transformer","(","preprocessor",")",",","default","`","None","`","An","instance","of","a","transformer","(","preprocessor",")","compatible","with","the","scikit-learn","preprocessing","API","with","methods",":","fit",",","transform",",","fit_transform","and","inverse_transform",".","ColumnTransformers","are","not","allowed","since","they","do","not","have","inverse_transform","method",".","The","transformation","is","applied","to","`","y","`","before","training","the","forecaster",".","transformer_exog",":","object","transformer","(","preprocessor",")",",","default","`","None","`","An","instance","of","a","transformer","(","preprocessor",")","compatible","with","the","scikit-learn","preprocessing","API",".","The","transformation","is","applied","to","`","exog","`","before","training","the","forecaster",".","`","inverse_transform","`","is","not","available","when","using","ColumnTransformers",".","weight_func",":","Callable",",","default","`","None","`","Function","that","defines","the","individual","weights","for","each","sample","based","on","the","index",".","For","example",",","a","function","that","assigns","a","lower","weight","to","certain","dates",".","Ignored","if","`","regressor","`","does","not","have","the","argument","`","sample_weight","`","in","its","`","fit","`","method",".","The","resulting","`","sample_weight","`","can","not","have","negative","values",".","differentiation",":","int",",","default","`","None","`","Order","of","differencing","applied","to","the","time","series","before","training","the","forecaster",".","If","`","None","`",",","no","differencing","is","applied",".","The","order","of","differentiation","is","the","number","of","times","the","differencing","operation","is","applied","to","a","time","series",".","Differencing","involves","computing","the","differences","between","consecutive","data","points","in","the","series",".","Diferentiarion","is","reversed","in","the","output","of","`","predict","(",")","`","and","`","predict_interval","(",")","`",".","*","*","WARNING",":","This","argument","is","newly","introduced","and","requires","special","attention",".","It","is","still","experimental","and","may","undergo","changes",".","*","*","*","*","New","in","version","0.10.0","*","*","fit_kwargs",":","dict",",","default","`","None","`","Additional","arguments","to","be","passed","to","the","`","fit","`","method","of","the","regressor",".","forecaster_id",":","str",",","int",",","default","`","None","`","Name","used","as","an","identifier","of","the","forecaster",".","Attributes","--","--","--","--","--","regressor",":","regressor","compatible","with","the","scikit-learn","API","An","instance","of","a","regressor","compatible","with","the","scikit-learn","API",".","fun_predictors",":","Callable","Function","that","receives","a","time","series","as","input","(","numpy","ndarray",")","and","returns","another","numpy","ndarray","with","the","predictors",".","source_code_fun_predictors",":","str","Source","code","of","the","custom","function","used","to","create","the","predictors",".","window_size",":","int","Size","of","the","window","needed","by","`","fun_predictors","`","to","create","the","predictors",".","If","`","differentiation","`","is","not","`","None","`",",","`","window_size","`","is","increased","by","the","order","of","differentiation",".","name_predictors",":","list","Name","of","the","predictors","returned","by","`","fun_predictors","`",".","If","`","None","`",",","predictors","are","named","using","the","prefix","'custom_predictor_","<","i",">","'","where","`","i","`","is","the","index","of","the","position","the","predictor","has","in","the","returned","array","of","`","fun_predictors","`",".","transformer_y",":","object","transformer","(","preprocessor",")","An","instance","of","a","transformer","(","preprocessor",")","compatible","with","the","scikit-learn","preprocessing","API","with","methods",":","fit",",","transform",",","fit_transform","and","inverse_transform",".","ColumnTransformers","are","not","allowed","since","they","do","not","have","inverse_transform","method",".","The","transformation","is","applied","to","`","y","`","before","training","the","forecaster",".","transformer_exog",":","object","transformer","(","preprocessor",")","An","instance","of","a","transformer","(","preprocessor",")","compatible","with","the","scikit-learn","preprocessing","API",".","The","transformation","is","applied","to","`","exog","`","before","training","the","forecaster",".","`","inverse_transform","`","is","not","available","when","using","ColumnTransformers",".","weight_func",":","Callable","Function","that","defines","the","individual","weights","for","each","sample","based","on","the","index",".","For","example",",","a","function","that","assigns","a","lower","weight","to","certain","dates",".","Ignored","if","`","regressor","`","does","not","have","the","argument","`","sample_weight","`","in","its","`","fit","`","method",".","The","resulting","`","sample_weight","`","can","not","have","negative","values",".","differentiation",":","int",",","default","`","None","`","Order","of","differencing","applied","to","the","time","series","before","training","the","forecaster",".","If","`","None","`",",","no","differencing","is","applied",".","The","order","of","differentiation","is","the","number","of","times","the","differencing","operation","is","applied","to","a","time","series",".","Differencing","involves","computing","the","differences","between","consecutive","data","points","in","the","series",".","Differentiation","is","reversed","in","the","output","of","`","predict","(",")","`","and","`","predict_interval","(",")","`",".","*","*","WARNING",":","This","argument","is","newly","introduced","and","requires","special","attention",".","It","is","still","experimental","and","may","undergo","changes",".","*","*","*","*","New","in","version","0.10.0","*","*","source_code_weight_func",":","str","Source","code","of","the","custom","function","used","to","create","weights",".","last_window",":","pandas","Series","This","window","represents","the","most","recent","data","observed","by","the","predictor","during","its","training","phase",".","It","contains","the","values","needed","to","predict","the","next","step","immediately","after","the","training","data",".","These","values","are","stored","in","the","original","scale","of","the","time","series","before","undergoing","any","transformations","or","differentiation",".","When","`","differentiation","`","parameter","is","specified",",","the","dimensions","of","the","`","last_window","`","are","expanded","as","many","values","as","the","order","of","differentiation",".","For","example",",","if","`","fun_predictors","(",")","`","requires","7","lagged","values","and","`","differentiation=1","`",",","`","last_window","`","will","contain","8","values",".","index_type",":","type","Type","of","index","of","the","input","used","in","training",".","index_freq",":","str","Frequency","of","Index","of","the","input","used","in","training",".","training_range",":","pandas","Index","First","and","last","values","of","index","of","the","data","used","during","training",".","included_exog",":","bool","If","the","forecaster","has","been","trained","using","exogenous","variable\/s",".","exog_type",":","type","Type","of","exogenous","data","(","pandas","Series","or","DataFrame",")","used","in","training",".","exog_dtypes",":","dict","Type","of","each","exogenous","variable\/s","used","in","training",".","If","`","transformer_exog","`","is","used",",","the","dtypes","are","calculated","after","the","transformation",".","exog_col_names",":","list","Names","of","columns","of","`","exog","`","if","`","exog","`","used","in","training","was","a","pandas","DataFrame",".","X_train_col_names",":","list","Names","of","columns","of","the","matrix","created","internally","for","training",".","fit_kwargs",":","dict","Additional","arguments","to","be","passed","to","the","`","fit","`","method","of","the","regressor",".","in_sample_residuals",":","numpy","ndarray","Residuals","of","the","model","when","predicting","training","data",".","Only","stored","up","to","1000","values",".","If","`","transformer_y","`","is","not","`","None","`",",","residuals","are","stored","in","the","transformed","scale",".","out_sample_residuals",":","numpy","ndarray","Residuals","of","the","model","when","predicting","non","training","data",".","Only","stored","up","to","1000","values",".","If","`","transformer_y","`","is","not","`","None","`",",","residuals","are","assumed","to","be","in","the","transformed","scale",".","Use","`","set_out_sample_residuals","`","method","to","set","values",".","fitted",":","bool","Tag","to","identify","if","the","regressor","has","been","fitted","(","trained",")",".","creation_date",":","str","Date","of","creation",".","fit_date",":","str","Date","of","last","fit",".","skforecast_version",":","str","Version","of","skforecast","library","used","to","create","the","forecaster",".","python_version",":","str","Version","of","python","used","to","create","the","forecaster",".","forecaster_id",":","str",",","int","Name","used","as","an","identifier","of","the","forecaster","."]
docstr: Training Forecaster.
  
  Additional arguments to be passed to the `fit` method of the regressor 
  can be added with the `fit_kwargs` argument when initializing the forecaster.
  
  Parameters
  ----------
  y : pandas Series
      Training time series.
  exog : pandas Series, pandas DataFrame, default `None`
      Exogenous variable/s included as predictor/s. Must have the same
      number of observations as `y` and their indexes must be aligned so
      that y[i] is regressed on exog[i].
  store_in_sample_residuals : bool, default `True`
      If `True`, in-sample residuals will be stored in the forecaster object
      after fitting.
  
  Returns
  -------
  None
code: def fit(
      self,
      y: pd.Series,
      exog: Optional[Union[pd.Series, pd.DataFrame]] = None,
      store_in_sample_residuals: bool = True,
  ) -> None:
      """
      Training Forecaster.
  
      Additional arguments to be passed to the `fit` method of the regressor
      can be added with the `fit_kwargs` argument when initializing the forecaster.
  
      Parameters
      ----------
      y : pandas Series
          Training time series.
      exog : pandas Series, pandas DataFrame, default `None`
          Exogenous variable/s included as predictor/s. Must have the same
          number of observations as `y` and their indexes must be aligned so
          that y[i] is regressed on exog[i].
      store_in_sample_residuals : bool, default `True`
          If `True`, in-sample residuals will be stored in the forecaster object
          after fitting.
  
      Returns
      -------
      None
  
      """
  
      # Reset values in case the forecaster has already been fitted.
      self.index_type = None
      self.index_freq = None
      self.last_window = None
      self.included_exog = False
      self.exog_type = None
      self.exog_dtypes = None
      self.exog_col_names = None
      self.X_train_col_names = None
      self.in_sample_residuals = None
      self.fitted = False
      self.training_range = None
  
      if exog is not None:
          self.included_exog = True
          self.exog_type = type(exog)
          self.exog_col_names = (
              exog.columns.to_list()
              if isinstance(exog, pd.DataFrame)
              else exog.name
          )
  
      X_train, y_train = self.create_train_X_y(y=y, exog=exog)
      sample_weight = self.create_sample_weights(X_train=X_train)
  
      if sample_weight is not None:
          self.regressor.fit(
              X=X_train,
              y=y_train,
              sample_weight=sample_weight,
              **self.fit_kwargs,
          )
      else:
          self.regressor.fit(X=X_train, y=y_train, **self.fit_kwargs)
  
      self.fitted = True
      self.fit_date = pd.Timestamp.today().strftime("%Y-%m-%d %H:%M:%S")
      self.training_range = preprocess_y(y=y, return_values=False)[1][
          [0, -1]
      ]
      self.index_type = type(X_train.index)
      if isinstance(X_train.index, pd.DatetimeIndex):
          self.index_freq = X_train.index.freqstr
      else:
          self.index_freq = X_train.index.step
  
      # This is done to save time during fit in functions such as backtesting()
      if store_in_sample_residuals:
          residuals = (
              y_train - self.regressor.predict(X_train)
          ).to_numpy()
  
          if len(residuals) > 1000:
              # Only up to 1000 residuals are stored
              rng = np.random.default_rng(seed=123)
              residuals = rng.choice(
                  a=residuals, size=1000, replace=False
              )
  
          self.in_sample_residuals = residuals
  
      # The last time window of training data is stored so that predictors in
      # the first iteration of `predict()` can be calculated. It also includes
      # the values need to calculate the diferenctiation.
      self.last_window = y.iloc[-self.window_size :].copy()
  
imports: from typing import Union, Tuple, Optional, Callable
  import warnings
  import logging
  import sys
  import numpy
  import pandas
  import sklearn
  import sklearn.pipeline
  from sklearn.base import clone
  import inspect
  import skforecast
  from ..ForecasterBase import ForecasterBase
  from ..utils import initialize_weights
  from ..utils import check_select_fit_kwargs
  from ..utils import check_y
  from ..utils import check_exog
  from ..utils import get_exog_dtypes
  from ..utils import check_exog_dtypes
  from ..utils import check_interval
  from ..utils import preprocess_y
  from ..utils import preprocess_last_window
  from ..utils import preprocess_exog
  from ..utils import expand_index
  from ..utils import check_predict_input
  from ..utils import transform_series
  from ..utils import transform_dataframe
  from ..preprocessing import TimeSeriesDifferentiator
label_desc: Use image node_id 5 for calling the ForecasterAutoregCustom obj's underlying member method code with example usage: obj.fit(y, exog, store_in_sample_residuals) without return types