class_docstr: Automated TimeSeries Estimator for time series forecasting task, which supports
  TSDataset and customized data creator as data input on built-in model (only
  "lstm", "tcn", "seq2seq" for now) and 3rd party model.
  
  Only backend="torch" is supported for now. Customized data creator has not been
  fully supported by TSPipeline.
  
  >>> # Here is a use case example:
  >>> # prepare train/valid/test tsdataset
  >>> autoest = AutoTSEstimator(model="lstm",
  >>>                           search_space=search_space,
  >>>                           past_seq_len=6,
  >>>                           future_seq_len=1)
  >>> tsppl = autoest.fit(data=tsdata_train,
  >>>                     validation_data=tsdata_valid)
  >>> tsppl.predict(tsdata_test)
  >>> tsppl.save("my_tsppl")
class_docstr_tok: ["Automated","TimeSeries","Estimator","for","time","series","forecasting","task",",","which","supports","TSDataset","and","customized","data","creator","as","data","input","on","built-in","model","(","only","''","lstm","''",",","``","tcn","''",",","``","seq2seq","''","for","now",")","and","3rd","party","model",".","Only","backend=","''","torch","''","is","supported","for","now",".","Customized","data","creator","has","not","been","fully","supported","by","TSPipeline",".",">",">",">","#","Here","is","a","use","case","example",":",">",">",">","#","prepare","train\/valid\/test","tsdataset",">",">",">","autoest","=","AutoTSEstimator","(","model=","''","lstm","''",",",">",">",">","search_space=search_space",",",">",">",">","past_seq_len=6",",",">",">",">","future_seq_len=1",")",">",">",">","tsppl","=","autoest.fit","(","data=tsdata_train",",",">",">",">","validation_data=tsdata_valid",")",">",">",">","tsppl.predict","(","tsdata_test",")",">",">",">","tsppl.save","(","``","my_tsppl","''",")"]
docstr: fit using AutoEstimator
  
  :param data: train data.
         For backend of "torch", data can be a TSDataset or a function that takes a
         config dictionary as parameter and returns a PyTorch DataLoader.
         For backend of "keras", data can be a TSDataset.
  :param epochs: Max number of epochs to train in each trial. Defaults to 1.
         If you have also set metric_threshold, a trial will stop if either it has been
         optimized to the metric_threshold or it has been trained for {epochs} epochs.
  :param batch_size: Int or hp sampling function from an integer space. Training batch size.
         It defaults to 32.
  :param validation_data: Validation data. Validation data type should be the same as data.
  :param metric_threshold: a trial will be terminated when metric threshold is met.
  :param n_sampling: Number of times to sample from the search_space. Defaults to 1.
         If hp.grid_search is in search_space, the grid will be repeated n_sampling of times.
         If this is -1, (virtually) infinite samples are generated
         until a stopping condition is met.
  :param search_alg: str, all supported searcher provided by ray tune
         (i.e."variant_generator", "random", "ax", "dragonfly", "skopt",
         "hyperopt", "bayesopt", "bohb", "nevergrad", "optuna", "zoopt" and
         "sigopt")
  :param search_alg_params: extra parameters for searcher algorithm besides search_space,
         metric and searcher mode
  :param scheduler: str, all supported scheduler provided by ray tune
  :param scheduler_params: parameters for scheduler
  
  :return: a TSPipeline with the best model.
docstr_tok: ["fit","using","AutoEstimator",":","param","data",":","train","data",".","For","backend","of","``","torch","''",",","data","can","be","a","TSDataset","or","a","function","that","takes","a","config","dictionary","as","parameter","and","returns","a","PyTorch","DataLoader",".","For","backend","of","``","keras","''",",","data","can","be","a","TSDataset",".",":","param","epochs",":","Max","number","of","epochs","to","train","in","each","trial",".","Defaults","to","1",".","If","you","have","also","set","metric_threshold",",","a","trial","will","stop","if","either","it","has","been","optimized","to","the","metric_threshold","or","it","has","been","trained","for","{","epochs","}","epochs",".",":","param","batch_size",":","Int","or","hp","sampling","function","from","an","integer","space",".","Training","batch","size",".","It","defaults","to","32.",":","param","validation_data",":","Validation","data",".","Validation","data","type","should","be","the","same","as","data",".",":","param","metric_threshold",":","a","trial","will","be","terminated","when","metric","threshold","is","met",".",":","param","n_sampling",":","Number","of","times","to","sample","from","the","search_space",".","Defaults","to","1",".","If","hp.grid_search","is","in","search_space",",","the","grid","will","be","repeated","n_sampling","of","times",".","If","this","is","-1",",","(","virtually",")","infinite","samples","are","generated","until","a","stopping","condition","is","met",".",":","param","search_alg",":","str",",","all","supported","searcher","provided","by","ray","tune","(","i.e",".","``","variant_generator","''",",","``","random","''",",","``","ax","''",",","``","dragonfly","''",",","``","skopt","''",",","``","hyperopt","''",",","``","bayesopt","''",",","``","bohb","''",",","``","nevergrad","''",",","``","optuna","''",",","``","zoopt","''","and","``","sigopt","''",")",":","param","search_alg_params",":","extra","parameters","for","searcher","algorithm","besides","search_space",",","metric","and","searcher","mode",":","param","scheduler",":","str",",","all","supported","scheduler","provided","by","ray","tune",":","param","scheduler_params",":","parameters","for","scheduler",":","return",":","a","TSPipeline","with","the","best","model","."]
code: def fit(
      self,
      data,
      epochs=1,
      batch_size=32,
      validation_data=None,
      metric_threshold=None,
      n_sampling=1,
      search_alg=None,
      search_alg_params=None,
      scheduler=None,
      scheduler_params=None,
  ):
      """
      fit using AutoEstimator
  
      :param data: train data.
             For backend of "torch", data can be a TSDataset or a function that takes a
             config dictionary as parameter and returns a PyTorch DataLoader.
             For backend of "keras", data can be a TSDataset.
      :param epochs: Max number of epochs to train in each trial. Defaults to 1.
             If you have also set metric_threshold, a trial will stop if either it has been
             optimized to the metric_threshold or it has been trained for {epochs} epochs.
      :param batch_size: Int or hp sampling function from an integer space. Training batch size.
             It defaults to 32.
      :param validation_data: Validation data. Validation data type should be the same as data.
      :param metric_threshold: a trial will be terminated when metric threshold is met.
      :param n_sampling: Number of times to sample from the search_space. Defaults to 1.
             If hp.grid_search is in search_space, the grid will be repeated n_sampling of times.
             If this is -1, (virtually) infinite samples are generated
             until a stopping condition is met.
      :param search_alg: str, all supported searcher provided by ray tune
             (i.e."variant_generator", "random", "ax", "dragonfly", "skopt",
             "hyperopt", "bayesopt", "bohb", "nevergrad", "optuna", "zoopt" and
             "sigopt")
      :param search_alg_params: extra parameters for searcher algorithm besides search_space,
             metric and searcher mode
      :param scheduler: str, all supported scheduler provided by ray tune
      :param scheduler_params: parameters for scheduler
  
      :return: a TSPipeline with the best model.
      """
      is_third_party_model = isinstance(self.model, AutoEstimator)
  
      # generate data creator from TSDataset (pytorch base require validation data)
      if isinstance(data, TSDataset) and isinstance(
          validation_data, TSDataset
      ):
          train_d, val_d = self._prepare_data_creator(
              search_space=self.search_space
              if is_third_party_model
              else self.model.search_space,
              train_data=data,
              val_data=validation_data,
          )
          self._scaler = data.scaler
          self._scaler_index = data.scaler_index
      else:
          train_d, val_d = data, validation_data
  
      if is_third_party_model:
          self.search_space.update({"batch_size": batch_size})
          self.model.fit(
              data=train_d,
              epochs=epochs,
              validation_data=val_d,
              metric=self.metric,
              metric_threshold=metric_threshold,
              n_sampling=n_sampling,
              search_space=self.search_space,
              search_alg=search_alg,
              search_alg_params=search_alg_params,
              scheduler=scheduler,
              scheduler_params=scheduler_params,
          )
  
      if not is_third_party_model:
          self.model.fit(
              data=train_d,
              epochs=epochs,
              batch_size=batch_size,
              validation_data=val_d,
              metric_threshold=metric_threshold,
              n_sampling=n_sampling,
              search_alg=search_alg,
              search_alg_params=search_alg_params,
              scheduler=scheduler,
              scheduler_params=scheduler_params,
          )
  
      return TSPipeline(
          best_model=self._get_best_automl_model(),
          best_config=self.get_best_config(),
          scaler=self._scaler,
          scaler_index=self._scaler_index,
      )
  
file_path: analytics-zoo/pyzoo/zoo/chronos/autots/autotsestimator.py
imports: import types
  from zoo.orca.automl.auto_estimator import AutoEstimator
  from zoo.chronos.data import TSDataset
  import zoo.orca.automl.hp
  from zoo.chronos.autots.model import AutoModelFactory
  from zoo.chronos.autots.tspipeline import TSPipeline
label_desc: Use image node_id 2 for calling the AutoTSEstimator obj's underlying member method code with example usage: obj.fit(data, epochs, batch_size, validation_data, metric_threshold, n_sampling, search_alg, search_alg_params, scheduler, scheduler_params) and returns: TSPipeline