class_docstr: Trend based forecasts of time series data, regressing values on index.
  
  Uses a `sklearn` regressor specified by the `regressor` parameter
  to perform regression on time series values against their corresponding indices,
  providing trend-based forecasts:
  
  In `fit`, for input time series :math:`(v_i, t_i), i = 1, \dots, T`,
  where :math:`v_i` are values and :math:`t_i` are time stamps,
  fits an `sklearn` model :math:`v_i = f(t_i) + \epsilon_i`, where `f` is
  the model fitted when `regressor.fit` is passed `X` = vector of :math:`t_i`,
  and `y` = vector of :math:`v_i`.
  
  In `predict`, for a new time point :math:`t_*`, predicts :math:`f(t_*)`,
  where :math:`f` is the function as fitted above in `fit`.
  
  Default for `regressor` is linear regression = `sklearn` `LinearRegression` default.
  
  If time stamps are `pd.DatetimeIndex`, fitted coefficients are in units
  of days since start of 1970. If time stamps are `pd.PeriodIndex`,
  coefficients are in units of (full) periods since start of 1970.
  
  Parameters
  ----------
  regressor : estimator object, default = None
      Define the regression model type. If not set, will default to
       sklearn.linear_model.LinearRegression
  
  Examples
  --------
  >>> from sktime.datasets import load_airline
  >>> from sktime.forecasting.trend import TrendForecaster
  >>> y = load_airline()
  >>> forecaster = TrendForecaster()
  >>> forecaster.fit(y)
  TrendForecaster(...)
  >>> y_pred = forecaster.predict(fh=[1,2,3])
class_docstr_tok: ["Trend","based","forecasts","of","time","series","data",",","regressing","values","on","index",".","Uses","a","`","sklearn","`","regressor","specified","by","the","`","regressor","`","parameter","to","perform","regression","on","time","series","values","against","their","corresponding","indices",",","providing","trend-based","forecasts",":","In","`","fit","`",",","for","input","time","series",":","math",":","`","(","v_i",",","t_i",")",",","i","=","1",",","\\dots",",","T","`",",","where",":","math",":","`","v_i","`","are","values","and",":","math",":","`","t_i","`","are","time","stamps",",","fits","an","`","sklearn","`","model",":","math",":","`","v_i","=","f","(","t_i",")","+","\\epsilon_i","`",",","where","`","f","`","is","the","model","fitted","when","`","regressor.fit","`","is","passed","`","X","`","=","vector","of",":","math",":","`","t_i","`",",","and","`","y","`","=","vector","of",":","math",":","`","v_i","`",".","In","`","predict","`",",","for","a","new","time","point",":","math",":","`","t_","*","`",",","predicts",":","math",":","`","f","(","t_","*",")","`",",","where",":","math",":","`","f","`","is","the","function","as","fitted","above","in","`","fit","`",".","Default","for","`","regressor","`","is","linear","regression","=","`","sklearn","`","`","LinearRegression","`","default",".","If","time","stamps","are","`","pd.DatetimeIndex","`",",","fitted","coefficients","are","in","units","of","days","since","start","of","1970",".","If","time","stamps","are","`","pd.PeriodIndex","`",",","coefficients","are","in","units","of","(","full",")","periods","since","start","of","1970",".","Parameters","--","--","--","--","--","regressor",":","estimator","object",",","default","=","None","Define","the","regression","model","type",".","If","not","set",",","will","default","to","sklearn.linear_model.LinearRegression","Examples","--","--","--","--",">",">",">","from","sktime.datasets","import","load_airline",">",">",">","from","sktime.forecasting.trend","import","TrendForecaster",">",">",">","y","=","load_airline","(",")",">",">",">","forecaster","=","TrendForecaster","(",")",">",">",">","forecaster.fit","(","y",")","TrendForecaster","(","...",")",">",">",">","y_pred","=","forecaster.predict","(","fh=","[","1,2,3","]",")"]
docstr: Fit to training data.
  
  Parameters
  ----------
  y : pd.Series
      Target time series with which to fit the forecaster.
  X : pd.DataFrame, default=None
      Exogenous variables are ignored
  fh : int, list or np.array, optional (default=None)
      The forecasters horizon with the steps ahead to to predict.
  
  Returns
  -------
  self : returns an instance of self.
docstr_tok: ["Fit","to","training","data",".","Parameters","--","--","--","--","--","y",":","pd.Series","Target","time","series","with","which","to","fit","the","forecaster",".","X",":","pd.DataFrame",",","default=None","Exogenous","variables","are","ignored","fh",":","int",",","list","or","np.array",",","optional","(","default=None",")","The","forecasters","horizon","with","the","steps","ahead","to","to","predict",".","Returns","--","--","--","-","self",":","returns","an","instance","of","self","."]
code: def _fit(self, y, X, fh):
      """Fit to training data.
  
      Parameters
      ----------
      y : pd.Series
          Target time series with which to fit the forecaster.
      X : pd.DataFrame, default=None
          Exogenous variables are ignored
      fh : int, list or np.array, optional (default=None)
          The forecasters horizon with the steps ahead to to predict.
  
      Returns
      -------
      self : returns an instance of self.
      """
      if self.regressor is None:
          self.regressor_ = LinearRegression(fit_intercept=True)
      else:
          self.regressor_ = clone(self.regressor)
  
      # we regress index on series values
      # the sklearn X is obtained from the index of y
      # the sklearn y can be taken as the y seen here
      X_sklearn = _get_X_numpy_int_from_pandas(y.index)
  
      # fit regressor
      self.regressor_.fit(X_sklearn, y)
      return self
  
file_path: sktime/sktime/forecasting/trend/_trend_forecaster.py
imports: import pandas
  from sklearn.base import clone
  from sklearn.linear_model import LinearRegression
  from sktime.forecasting.base import BaseForecaster
  from sktime.forecasting.trend._util import _get_X_numpy_int_from_pandas
label_desc: Use image node_id 2 for calling the TrendForecaster obj's underlying member method code with example usage: obj._fit(y, X, fh) and returns: self