class_docstr: Defines Temporal Fusion Transformer.
  
  Attributes:
    name: Name of model
    time_steps: Total number of input time steps per forecast date (i.e. Width
      of Temporal fusion decoder N)
    input_size: Total number of inputs
    output_size: Total number of outputs
    category_counts: Number of categories per categorical variable
    n_multiprocessing_workers: Number of workers to use for parallel
      computations
    column_definition: List of tuples of (string, DataType, InputType) that
      define each column
    quantiles: Quantiles to forecast for TFT
    use_cudnn: Whether to use Keras CuDNNLSTM or standard LSTM layers
    hidden_layer_size: Internal state size of TFT
    dropout_rate: Dropout discard rate
    max_gradient_norm: Maximum norm for gradient clipping
    learning_rate: Initial learning rate of ADAM optimizer
    minibatch_size: Size of minibatches for training
    num_epochs: Maximum number of epochs for training
    early_stopping_patience: Maximum number of iterations of non-improvement
      before early stopping kicks in
    num_encoder_steps: Size of LSTM encoder -- i.e. number of past time steps
      before forecast date to use
    num_stacks: Number of self-attention layers to apply (default is 1 for basic
      TFT)
    num_heads: Number of heads for interpretable mulit-head attention
    model: Keras model for TFT
class_docstr_tok: ["Defines","Temporal","Fusion","Transformer",".","Attributes",":","name",":","Name","of","model","time_steps",":","Total","number","of","input","time","steps","per","forecast","date","(","i.e",".","Width","of","Temporal","fusion","decoder","N",")","input_size",":","Total","number","of","inputs","output_size",":","Total","number","of","outputs","category_counts",":","Number","of","categories","per","categorical","variable","n_multiprocessing_workers",":","Number","of","workers","to","use","for","parallel","computations","column_definition",":","List","of","tuples","of","(","string",",","DataType",",","InputType",")","that","define","each","column","quantiles",":","Quantiles","to","forecast","for","TFT","use_cudnn",":","Whether","to","use","Keras","CuDNNLSTM","or","standard","LSTM","layers","hidden_layer_size",":","Internal","state","size","of","TFT","dropout_rate",":","Dropout","discard","rate","max_gradient_norm",":","Maximum","norm","for","gradient","clipping","learning_rate",":","Initial","learning","rate","of","ADAM","optimizer","minibatch_size",":","Size","of","minibatches","for","training","num_epochs",":","Maximum","number","of","epochs","for","training","early_stopping_patience",":","Maximum","number","of","iterations","of","non-improvement","before","early","stopping","kicks","in","num_encoder_steps",":","Size","of","LSTM","encoder","--","i.e",".","number","of","past","time","steps","before","forecast","date","to","use","num_stacks",":","Number","of","self-attention","layers","to","apply","(","default","is","1","for","basic","TFT",")","num_heads",":","Number","of","heads","for","interpretable","mulit-head","attention","model",":","Keras","model","for","TFT"]
docstr: Applies evaluation metric to the training data.
  
  Args:
    data: Dataframe for evaluation
    eval_metric: Evaluation metic to return, based on model definition.
  
  Returns:
    Computed evaluation loss.
docstr_tok: ["Applies","evaluation","metric","to","the","training","data",".","Args",":","data",":","Dataframe","for","evaluation","eval_metric",":","Evaluation","metic","to","return",",","based","on","model","definition",".","Returns",":","Computed","evaluation","loss","."]
code: def evaluate(self, data=None, eval_metric="loss"):
      """Applies evaluation metric to the training data.
  
      Args:
        data: Dataframe for evaluation
        eval_metric: Evaluation metic to return, based on model definition.
  
      Returns:
        Computed evaluation loss.
      """
  
      if data is None:
          print("Using cached validation data")
          raw_data = TFTDataCache.get("valid")
      else:
          raw_data = self._batch_data(data)
  
      inputs = raw_data["inputs"]
      outputs = raw_data["outputs"]
      active_entries = self._get_active_locations(
          raw_data["active_entries"]
      )
  
      metric_values = self.model.evaluate(
          x=inputs,
          y=np.concatenate([outputs, outputs, outputs], axis=-1),
          sample_weight=active_entries,
          workers=16,
          use_multiprocessing=True,
      )
  
      metrics = pd.Series(metric_values, self.model.metrics_names)
  
      return metrics[eval_metric]
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gc
  import json
  import os
  import shutil
  import data_formatters.base
  import libs.utils
  import numpy
  import pandas
  import tensorflow
label_desc: Use image node_id 12 for calling the TemporalFusionTransformer obj's underlying member method code with example usage: obj.evaluate(data, eval_metric) and returns: metrics