class_docstr: Callback function used to calculate the NDCG@k metric of validation set at the end of each epoch.
  Weights of the model with the highest NDCG@k value is saved.
docstr: Initialize the class parameters.
  
  Args:
      model: trained model for validation.
      val_tr (numpy.ndarray, float): the click matrix for the validation set training part.
      val_te (numpy.ndarray, float): the click matrix for the validation set testing part.
      mapper (AffinityMatrix): the mapper for converting click matrix to dataframe.
      k (int): number of top k items per user (optional).
      save_path (str): Default path to save weights.
code: def __init__(self, model, val_tr, val_te, mapper, k, save_path=None):
      """Initialize the class parameters.
  
      Args:
          model: trained model for validation.
          val_tr (numpy.ndarray, float): the click matrix for the validation set training part.
          val_te (numpy.ndarray, float): the click matrix for the validation set testing part.
          mapper (AffinityMatrix): the mapper for converting click matrix to dataframe.
          k (int): number of top k items per user (optional).
          save_path (str): Default path to save weights.
      """
      # Model
      self.model = model
  
      # Initial value of NDCG
      self.best_ndcg = 0.0
  
      # Validation data: training and testing parts
      self.val_tr = val_tr
      self.val_te = val_te
  
      # Mapper for converting from sparse matrix to dataframe
      self.mapper = mapper
  
      # Top k items to recommend
      self.k = k
  
      # Options to save the weights of the model for future use
      self.save_path = save_path
  
imports: import numpy
  import matplotlib.pyplot
  import seaborn
  from recommenders.evaluation.python_evaluation import ndcg_at_k
  import tensorflow
  from tensorflow.keras.layers import *
  from tensorflow.keras.models import Model
  from tensorflow.keras import backend
  from tensorflow.keras.callbacks import ReduceLROnPlateau, Callback
label_desc: Use image node_id 1 to create a new Metrics object from inherited base classes: Callback with example: obj = Metrics(model, val_tr, val_te, mapper, k, save_path)