class_docstr: Example:
      >>> import numpy as np
      >>> model = TCMFForecaster()
      >>> fit_params = dict(val_len=12,
                         start_date="2020-1-1",
                         freq="5min",
                         y_iters=1,
                         init_FX_epoch=1,
                         max_FX_epoch=1,
                         max_TCN_epoch=1,
                         alt_iters=2)
      >>> ndarray_input = {'id': np.arange(300), 'y': np.random.rand(300, 480)}
      >>> model.fit(ndarray_input, fit_params)
      >>> horizon = np.random.randint(1, 50)
      >>> yhat = model.predict(horizon=horizon)
      >>> model.save({tempdirname})
      >>> loaded_model = TCMFForecaster.load({tempdirname}, is_xshards_distributed=False)
      >>> data_new = np.random.rand(300, horizon)
      >>> model.evaluate(target_value=dict({"y": data_new}), metric=['mse'])
      >>> model.fit_incremental({"y": data_new})
      >>> yhat_incr = model.predict(horizon=horizon)
class_docstr_tok: ["Example",":",">",">",">","import","numpy","as","np",">",">",">","model","=","TCMFForecaster","(",")",">",">",">","fit_params","=","dict","(","val_len=12",",","start_date=","''","2020-1-1","''",",","freq=","''","5min","''",",","y_iters=1",",","init_FX_epoch=1",",","max_FX_epoch=1",",","max_TCN_epoch=1",",","alt_iters=2",")",">",">",">","ndarray_input","=","{","'id","'",":","np.arange","(","300",")",",","'","y","'",":","np.random.rand","(","300",",","480",")","}",">",">",">","model.fit","(","ndarray_input",",","fit_params",")",">",">",">","horizon","=","np.random.randint","(","1",",","50",")",">",">",">","yhat","=","model.predict","(","horizon=horizon",")",">",">",">","model.save","(","{","tempdirname","}",")",">",">",">","loaded_model","=","TCMFForecaster.load","(","{","tempdirname","}",",","is_xshards_distributed=False",")",">",">",">","data_new","=","np.random.rand","(","300",",","horizon",")",">",">",">","model.evaluate","(","target_value=dict","(","{","``","y","''",":","data_new","}",")",",","metric=","[","'mse","'","]",")",">",">",">","model.fit_incremental","(","{","``","y","''",":","data_new","}",")",">",">",">","yhat_incr","=","model.predict","(","horizon=horizon",")"]
docstr: Fit the model on x from scratch
  
  :param x: the input for fit. Only dict of ndarray and SparkXShards of dict of ndarray
      are supported. Example: {'id': id_arr, 'y': data_ndarray}, and data_ndarray
      is of shape (n, T), where n is the number f target time series and T is the
      number of time steps.
  :param val_len: int, default is 24.
      Validation length. We will use the last val_len time points as validation data.
  :param start_date: str or datetime-like.
      Start date time for the time-series. e.g. "2020-01-01"
  :param freq: str or DateOffset, default is 'H'
      Frequency of data
  :param covariates: 2-D ndarray or None. The shape of ndarray should be (r, T), where r is
      the number of covariates and T is the number of time points.
      Global covariates for all time series. If None, only default time coveriates will be
      used while use_time is True. If not, the time coveriates used is the stack of input
      covariates and default time coveriates.
  :param dti: DatetimeIndex or None.
      If None, use default fixed frequency DatetimeIndex generated with start_date and freq.
  :param period: int, default is 24.
      Periodicity of input time series, leave it out if not known
  :param y_iters: int, default is 10.
      Number of iterations while training the hybrid model.
  :param init_FX_epoch: int, default is 100.
      Number of iterations while initializing factors
  :param max_FX_epoch: int, default is 300.
      Max number of iterations while training factors.
  :param max_TCN_epoch: int, default is 300.
      Max number of iterations while training the local model.
  :param alt_iters: int, default is 10.
      Number of iterations while alternate training.
  :param num_workers: the number of workers you want to use for fit. If None, it defaults to
      num_ray_nodes in the created RayContext or 1 if there is no active RayContext.
docstr_tok: ["Fit","the","model","on","x","from","scratch",":","param","x",":","the","input","for","fit",".","Only","dict","of","ndarray","and","SparkXShards","of","dict","of","ndarray","are","supported",".","Example",":","{","'id","'",":","id_arr",",","'","y","'",":","data_ndarray","}",",","and","data_ndarray","is","of","shape","(","n",",","T",")",",","where","n","is","the","number","f","target","time","series","and","T","is","the","number","of","time","steps",".",":","param","val_len",":","int",",","default","is","24",".","Validation","length",".","We","will","use","the","last","val_len","time","points","as","validation","data",".",":","param","start_date",":","str","or","datetime-like",".","Start","date","time","for","the","time-series",".","e.g",".","``","2020-01-01","''",":","param","freq",":","str","or","DateOffset",",","default","is","'","H'","Frequency","of","data",":","param","covariates",":","2-D","ndarray","or","None",".","The","shape","of","ndarray","should","be","(","r",",","T",")",",","where","r","is","the","number","of","covariates","and","T","is","the","number","of","time","points",".","Global","covariates","for","all","time","series",".","If","None",",","only","default","time","coveriates","will","be","used","while","use_time","is","True",".","If","not",",","the","time","coveriates","used","is","the","stack","of","input","covariates","and","default","time","coveriates",".",":","param","dti",":","DatetimeIndex","or","None",".","If","None",",","use","default","fixed","frequency","DatetimeIndex","generated","with","start_date","and","freq",".",":","param","period",":","int",",","default","is","24",".","Periodicity","of","input","time","series",",","leave","it","out","if","not","known",":","param","y_iters",":","int",",","default","is","10",".","Number","of","iterations","while","training","the","hybrid","model",".",":","param","init_FX_epoch",":","int",",","default","is","100",".","Number","of","iterations","while","initializing","factors",":","param","max_FX_epoch",":","int",",","default","is","300",".","Max","number","of","iterations","while","training","factors",".",":","param","max_TCN_epoch",":","int",",","default","is","300",".","Max","number","of","iterations","while","training","the","local","model",".",":","param","alt_iters",":","int",",","default","is","10",".","Number","of","iterations","while","alternate","training",".",":","param","num_workers",":","the","number","of","workers","you","want","to","use","for","fit",".","If","None",",","it","defaults","to","num_ray_nodes","in","the","created","RayContext","or","1","if","there","is","no","active","RayContext","."]
code: def fit(
      self,
      x,
      val_len=24,
      start_date="2020-4-1",
      freq="1H",
      covariates=None,
      dti=None,
      period=24,
      y_iters=10,
      init_FX_epoch=100,
      max_FX_epoch=300,
      max_TCN_epoch=300,
      alt_iters=10,
      num_workers=None,
  ):
      """
      Fit the model on x from scratch
  
      :param x: the input for fit. Only dict of ndarray and SparkXShards of dict of ndarray
          are supported. Example: {'id': id_arr, 'y': data_ndarray}, and data_ndarray
          is of shape (n, T), where n is the number f target time series and T is the
          number of time steps.
      :param val_len: int, default is 24.
          Validation length. We will use the last val_len time points as validation data.
      :param start_date: str or datetime-like.
          Start date time for the time-series. e.g. "2020-01-01"
      :param freq: str or DateOffset, default is 'H'
          Frequency of data
      :param covariates: 2-D ndarray or None. The shape of ndarray should be (r, T), where r is
          the number of covariates and T is the number of time points.
          Global covariates for all time series. If None, only default time coveriates will be
          used while use_time is True. If not, the time coveriates used is the stack of input
          covariates and default time coveriates.
      :param dti: DatetimeIndex or None.
          If None, use default fixed frequency DatetimeIndex generated with start_date and freq.
      :param period: int, default is 24.
          Periodicity of input time series, leave it out if not known
      :param y_iters: int, default is 10.
          Number of iterations while training the hybrid model.
      :param init_FX_epoch: int, default is 100.
          Number of iterations while initializing factors
      :param max_FX_epoch: int, default is 300.
          Max number of iterations while training factors.
      :param max_TCN_epoch: int, default is 300.
          Max number of iterations while training the local model.
      :param alt_iters: int, default is 10.
          Number of iterations while alternate training.
      :param num_workers: the number of workers you want to use for fit. If None, it defaults to
          num_ray_nodes in the created RayContext or 1 if there is no active RayContext.
      """
      if self.internal is None:
          if isinstance(x, SparkXShards):
              self.internal = TCMFXshardsModelWrapper(self.config)
          elif isinstance(x, dict):
              self.internal = TCMFNdarrayModelWrapper(self.config)
          else:
              raise ValueError(
                  "value of x should be a dict of ndarray or "
                  "an xShards of dict of ndarray"
              )
  
          try:
              self.internal.fit(
                  x,
                  num_workers=num_workers,
                  val_len=val_len,
                  start_date=start_date,
                  freq=freq,
                  covariates=covariates,
                  dti=dti,
                  period=period,
                  y_iters=y_iters,
                  init_FX_epoch=init_FX_epoch,
                  max_FX_epoch=max_FX_epoch,
                  max_TCN_epoch=max_TCN_epoch,
                  alt_iters=alt_iters,
              )
          except Exception as inst:
              self.internal = None
              raise inst
      else:
          raise Exception(
              "This model has already been fully trained, "
              "you can only run full training once."
          )
  
file_path: analytics-zoo/pyzoo/zoo/chronos/forecaster/tcmf_forecaster.py
imports: from zoo.chronos.model.tcmf_model import TCMFNdarrayModelWrapper, TCMFXshardsModelWrapper
  from zoo.orca.data import SparkXShards
  from zoo.chronos.forecaster.abstract import Forecaster
label_desc: Use image node_id 2 for calling the TCMFForecaster obj's underlying member method code with example usage: obj.fit(x, val_len, start_date, freq, covariates, dti, period, y_iters, init_FX_epoch, max_FX_epoch, max_TCN_epoch, alt_iters, num_workers) without return types