code: def novelty(
      train_df,
      reco_df,
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
  ):
      """Calculate the average novelty in a list of recommended items (this assumes that the recommendation list
      is already computed). Follows section 5 from
  
      :Citation:
  
          P. Castells, S. Vargas, and J. Wang, Novelty and diversity metrics for recommender systems:
          choice, discovery and relevance, ECIR 2011
  
      Args:
          train_df (pandas.DataFrame): Data set with historical data for users and items they
                  have interacted with; contains col_user, col_item. Assumed to not contain any duplicate rows.
                  Interaction here follows the *item choice model* from Castells et al.
          reco_df (pandas.DataFrame): Recommender's prediction output, containing col_user, col_item,
                  col_relevance (optional). Assumed to not contain any duplicate user-item pairs.
          col_user (str): User id column name.
          col_item (str): Item id column name.
  
      Returns:
          float: novelty.
      """
  
      df_item_novelty = historical_item_novelty(
          train_df, reco_df, col_user, col_item
      )
      n_recommendations = reco_df.shape[0]
      reco_item_count = pd.DataFrame(
          {"count": reco_df.groupby([col_item]).size()}
      ).reset_index()
      reco_item_novelty = reco_item_count.merge(
          df_item_novelty, on=col_item
      )
      reco_item_novelty["product"] = (
          reco_item_novelty["count"] * reco_item_novelty["item_novelty"]
      )
      avg_novelty = (
          reco_item_novelty.agg({"product": "sum"})[0]
          / n_recommendations
      )
  
      return avg_novelty
  
imports: import numpy
  import pandas
  from functools import wraps
  from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score, explained_variance_score, roc_auc_score, log_loss
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_PREDICTION_COL, DEFAULT_RELEVANCE_COL, DEFAULT_SIMILARITY_COL, DEFAULT_ITEM_FEATURES_COL, DEFAULT_ITEM_SIM_MEASURE, DEFAULT_K, DEFAULT_THRESHOLD
  from recommenders.datasets.pandas_df_utils import has_columns, has_same_base_dtype, lru_cache_df
label_desc: Use image node_id 27 for calling a global function with example usage: novelty(train_df, reco_df, col_user, col_item) and returns: avg_novelty