docstr: Please note that evaluate result is calculated by scaled y and yhat. If you scaled
  your data (e.g. use .scale() on the TSDataset) please follow the following code
  snap to evaluate your result if you need to evaluate on unscaled data.
  
  >>> from bigdl.chronos.metric.forecaster_metrics import Evaluator
  >>> y_hat = forecaster.predict(x)
  >>> y_hat_unscaled = tsdata.unscale_numpy(y_hat) # or other customized unscale methods
  >>> y_unscaled = tsdata.unscale_numpy(y) # or other customized unscale methods
  >>> Evaluator.evaluate(metric=..., y_unscaled, y_hat_unscaled, multioutput=...)
  
  :params data: The data support following formats:
  
          | 1. A numpy ndarray tuple (x, y):
          | 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.
          | y's shape is (num_samples, horizon, target_dim), where horizon and target_dim
          | should be the same as future_seq_len and output_feature_num.
          |
          | 2. A tf.data.Dataset:
          | A TFDataset instance which contains x and y with same shape as the tuple.
          | x's shape is (num_samples, lookback, feature_dim),
          | y's shape is (num_samples, horizon, target_dim).
          | If set distributed to True, we do not recommend using tf.data.Dataset,
          | please replace with tsdataset or numpy.ndarray.
          |
          | 3. A bigdl.chronos.data.tsdataset.TSDataset instance:
          | Forecaster will automatically process the TSDataset.
          | By default, TSDataset will be transformed to a tfdataset,
          | Users may call `roll` on the TSDataset before calling `fit`
          | Then the training speed will be faster but will consume more memory.
  
  :params batch_size: evaluate batch size. The value will not affect evaluate
          result but will affect resources cost(e.g. memory and time).
  :params multioutput_value: Defines aggregating of multiple output values.
          String in ['raw_values', 'uniform_average']. The value defaults to
          'raw_values'.The param is only effective when the forecaster is a
          non-distribtued version.
  :param quantize: if use the quantized model to predict.
  
  :return: A list of evaluation results. Each item represents a metric.
docstr_tok: ["Please","note","that","evaluate","result","is","calculated","by","scaled","y","and","yhat",".","If","you","scaled","your","data","(","e.g",".","use",".scale","(",")","on","the","TSDataset",")","please","follow","the","following","code","snap","to","evaluate","your","result","if","you","need","to","evaluate","on","unscaled","data",".",">",">",">","from","bigdl.chronos.metric.forecaster_metrics","import","Evaluator",">",">",">","y_hat","=","forecaster.predict","(","x",")",">",">",">","y_hat_unscaled","=","tsdata.unscale_numpy","(","y_hat",")","#","or","other","customized","unscale","methods",">",">",">","y_unscaled","=","tsdata.unscale_numpy","(","y",")","#","or","other","customized","unscale","methods",">",">",">","Evaluator.evaluate","(","metric=","...",",","y_unscaled",",","y_hat_unscaled",",","multioutput=","...",")",":","params","data",":","The","data","support","following","formats",":","|","1",".","A","numpy","ndarray","tuple","(","x",",","y",")",":","|","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",".","|","y","'s","shape","is","(","num_samples",",","horizon",",","target_dim",")",",","where","horizon","and","target_dim","|","should","be","the","same","as","future_seq_len","and","output_feature_num",".","|","|","2",".","A","tf.data.Dataset",":","|","A","TFDataset","instance","which","contains","x","and","y","with","same","shape","as","the","tuple",".","|","x","'s","shape","is","(","num_samples",",","lookback",",","feature_dim",")",",","|","y","'s","shape","is","(","num_samples",",","horizon",",","target_dim",")",".","|","If","set","distributed","to","True",",","we","do","not","recommend","using","tf.data.Dataset",",","|","please","replace","with","tsdataset","or","numpy.ndarray",".","|","|","3",".","A","bigdl.chronos.data.tsdataset.TSDataset","instance",":","|","Forecaster","will","automatically","process","the","TSDataset",".","|","By","default",",","TSDataset","will","be","transformed","to","a","tfdataset",",","|","Users","may","call","`","roll","`","on","the","TSDataset","before","calling","`","fit","`","|","Then","the","training","speed","will","be","faster","but","will","consume","more","memory",".",":","params","batch_size",":","evaluate","batch","size",".","The","value","will","not","affect","evaluate","result","but","will","affect","resources","cost","(","e.g",".","memory","and","time",")",".",":","params","multioutput_value",":","Defines","aggregating","of","multiple","output","values",".","String","in","[","'raw_values","'",",","'uniform_average","'","]",".","The","value","defaults","to","'raw_values'.The","param","is","only","effective","when","the","forecaster","is","a","non-distribtued","version",".",":","param","quantize",":","if","use","the","quantized","model","to","predict",".",":","return",":","A","list","of","evaluation","results",".","Each","item","represents","a","metric","."]
code: def evaluate(
      self,
      data,
      batch_size=32,
      multioutput="raw_values",
      quantize=False,
  ):
      """
      Please note that evaluate result is calculated by scaled y and yhat. If you scaled
      your data (e.g. use .scale() on the TSDataset) please follow the following code
      snap to evaluate your result if you need to evaluate on unscaled data.
  
      >>> from bigdl.chronos.metric.forecaster_metrics import Evaluator
      >>> y_hat = forecaster.predict(x)
      >>> y_hat_unscaled = tsdata.unscale_numpy(y_hat) # or other customized unscale methods
      >>> y_unscaled = tsdata.unscale_numpy(y) # or other customized unscale methods
      >>> Evaluator.evaluate(metric=..., y_unscaled, y_hat_unscaled, multioutput=...)
  
      :params data: The data support following formats:
  
              | 1. A numpy ndarray tuple (x, y):
              | 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.
              | y's shape is (num_samples, horizon, target_dim), where horizon and target_dim
              | should be the same as future_seq_len and output_feature_num.
              |
              | 2. A tf.data.Dataset:
              | A TFDataset instance which contains x and y with same shape as the tuple.
              | x's shape is (num_samples, lookback, feature_dim),
              | y's shape is (num_samples, horizon, target_dim).
              | If set distributed to True, we do not recommend using tf.data.Dataset,
              | please replace with tsdataset or numpy.ndarray.
              |
              | 3. A bigdl.chronos.data.tsdataset.TSDataset instance:
              | Forecaster will automatically process the TSDataset.
              | By default, TSDataset will be transformed to a tfdataset,
              | Users may call `roll` on the TSDataset before calling `fit`
              | Then the training speed will be faster but will consume more memory.
  
      :params batch_size: evaluate batch size. The value will not affect evaluate
              result but will affect resources cost(e.g. memory and time).
      :params multioutput_value: Defines aggregating of multiple output values.
              String in ['raw_values', 'uniform_average']. The value defaults to
              'raw_values'.The param is only effective when the forecaster is a
              non-distribtued version.
      :param quantize: if use the quantized model to predict.
  
      :return: A list of evaluation results. Each item represents a metric.
      """
      if isinstance(data, TSDataset):
          if data.lookback is None:
              data.roll(
                  lookback=self.model_config["past_seq_len"],
                  horizon=self.model_config["future_seq_len"],
              )
  
      invalidInputError(
          self.fitted,
          "You must call fit or restore first before calling evaluate!",
      )
  
      if self.distributed:
          if isinstance(data, tuple):
              data = np_to_data_creator(data, shuffle=False)
          if isinstance(data, TSDataset):
              data = tsdata_to_data_creator(data, shuffle=False)
          invalidInputError(
              not isinstance(data, tf.data.Dataset),
              "tf.data.Dataset is not supported, "
              "please replace with numpy.ndarray or TSDataset instance.",
          )
          return self.internal.evaluate(data, batch_size=batch_size)
      else:
          if isinstance(data, tuple):
              input_data, target = data
          elif isinstance(data, TSDataset):
              input_data, target = data.to_numpy()
          else:
              input_data = data
              target = np.concatenate(
                  list((map(lambda x: x[1], data.as_numpy_iterator())))
              )
          if quantize:
              invalidInputError(
                  self.accelerate_method == "tensorflow_int8",
                  "Can't find the quantized model, "
                  "please call .quantize() method first",
              )
              yhat = self.accelerated_model.predict(
                  input_data, batch_size=batch_size
              )
          else:
              yhat = self.internal.predict(
                  input_data, batch_size=batch_size
              )
  
          aggregate = (
              "mean" if multioutput == "uniform_average" else None
          )
          return Evaluator.evaluate(
              self.metrics,
              y_true=target,
              y_pred=yhat,
              aggregate=aggregate,
          )
  
imports: import warnings
  import keras
  import tensorflow
  import numpy
  from bigdl.chronos.forecaster.abstract import Forecaster
  from bigdl.chronos.data import TSDataset
  from bigdl.chronos.metric.forecast_metrics import Evaluator
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.chronos.forecaster.tf.utils import np_to_data_creator, tsdata_to_data_creator, np_to_xshards, xshard_to_np, np_to_tfdataset
label_desc: Use image node_id 5 for calling the BaseTF2Forecaster obj's underlying member method code with example usage: obj.evaluate(data, batch_size, multioutput, quantize) and returns: self, Evaluator