class_docstr: Forecaster base model for lstm, mtnet, seq2seq and tcn forecasters.
class_docstr_tok: ["Forecaster","base","model","for","lstm",",","mtnet",",","seq2seq","and","tcn","forecasters","."]
docstr: Predict using a trained forecaster.
  
  if you want to predict on a single node(which is common practice), please call
  .to_local().predict(x, ...)
  
  :param data: The data support following formats:
  
         | 1. a numpy ndarray x:
         | x's shape is (num_samples, lookback, feature_dim) where lookback and feature_dim
         | should be the same as past_seq_len and input_feature_num.
         | 2. a xshard item:
         | each partition can be a dictionary of {'x': x}, where x's shape
         | should follow the shape stated before.
  
  :param batch_size: predict batch size. The value will not affect predict
         result but will affect resources cost(e.g. memory and time).
  
  :return: A numpy array with shape (num_samples, horizon, target_dim)
           if data is a numpy ndarray. A xshard item with format {‘prediction’: result},
           where result is a numpy array with shape (num_samples, horizon, target_dim)
           if data is a xshard item.
docstr_tok: ["Predict","using","a","trained","forecaster",".","if","you","want","to","predict","on","a","single","node","(","which","is","common","practice",")",",","please","call",".to_local","(",")",".predict","(","x",",","...",")",":","param","data",":","The","data","support","following","formats",":","|","1.","a","numpy","ndarray","x",":","|","x","'s","shape","is","(","num_samples",",","lookback",",","feature_dim",")","where","lookback","and","feature_dim","|","should","be","the","same","as","past_seq_len","and","input_feature_num",".","|","2.","a","xshard","item",":","|","each","partition","can","be","a","dictionary","of","{","'","x","'",":","x","}",",","where","x","'s","shape","|","should","follow","the","shape","stated","before",".",":","param","batch_size",":","predict","batch","size",".","The","value","will","not","affect","predict","result","but","will","affect","resources","cost","(","e.g",".","memory","and","time",")",".",":","return",":","A","numpy","array","with","shape","(","num_samples",",","horizon",",","target_dim",")","if","data","is","a","numpy","ndarray",".","A","xshard","item","with","format","{","\u2018","prediction","\u2019",":","result","}",",","where","result","is","a","numpy","array","with","shape","(","num_samples",",","horizon",",","target_dim",")","if","data","is","a","xshard","item","."]
code: def predict(self, data, batch_size=32):
      """
      Predict using a trained forecaster.
  
      if you want to predict on a single node(which is common practice), please call
      .to_local().predict(x, ...)
  
      :param data: The data support following formats:
  
             | 1. a numpy ndarray x:
             | x's shape is (num_samples, lookback, feature_dim) where lookback and feature_dim
             | should be the same as past_seq_len and input_feature_num.
             | 2. a xshard item:
             | each partition can be a dictionary of {'x': x}, where x's shape
             | should follow the shape stated before.
  
      :param batch_size: predict batch size. The value will not affect predict
             result but will affect resources cost(e.g. memory and time).
  
      :return: A numpy array with shape (num_samples, horizon, target_dim)
               if data is a numpy ndarray. A xshard item with format {‘prediction’: result},
               where result is a numpy array with shape (num_samples, horizon, target_dim)
               if data is a xshard item.
      """
      # data transform
      is_local_data = isinstance(data, np.ndarray)
      if is_local_data and self.distributed:
          data = np_to_xshard(data)
      if not is_local_data and not self.distributed:
          data = xshard_to_np(data, mode="predict")
  
      if self.distributed:
          yhat = self.internal.predict(data, batch_size=batch_size)
          if is_local_data:
              expand_dim = []
              if self.data_config["future_seq_len"] == 1:
                  expand_dim.append(1)
              if self.data_config["output_feature_num"] == 1:
                  expand_dim.append(2)
              yhat = xshard_to_np(
                  yhat, mode="yhat", expand_dim=expand_dim
              )
          return yhat
      else:
          if not self.internal.model_built:
              raise RuntimeError(
                  "You must call fit or restore first before calling predict!"
              )
          yhat = self.internal.predict(data, batch_size=batch_size)
          if not is_local_data:
              yhat = np_to_xshard(yhat, prefix="prediction")
          return yhat
  
file_path: analytics-zoo/pyzoo/zoo/chronos/forecaster/base_forecaster.py
imports: from zoo.chronos.forecaster.abstract import Forecaster
  from zoo.orca.data.shard import SparkXShards
  from zoo.chronos.forecaster.utils import np_to_creator, set_pytorch_seed, check_data, xshard_to_np, np_to_xshard
  import numpy
  from zoo.orca.learn.pytorch.estimator import Estimator
  from zoo.orca.learn.metrics import MSE, MAE
label_desc: Use image node_id 3 for calling the BasePytorchForecaster obj's underlying member method code with example usage: obj.predict(data, batch_size) and returns: yhat, yhat