code: def fit_and_eval(
      model,
      user_features,
      item_features,
      train_interactions,
      test_interactions,
      fit_kwargs,
      recall_k=30,
      precision_k=5,
      ndcg_k=30,
  ):
      model.fit(
          user_features=user_features,
          item_features=item_features,
          interactions=train_interactions,
          **fit_kwargs,
      )
      predicted_ranks = model.predict_rank(
          user_features=user_features, item_features=item_features
      )
  
      p_at_k = precision_at_k(
          predicted_ranks, test_interactions, k=precision_k
      )
      r_at_k = recall_at_k(
          predicted_ranks, test_interactions, k=recall_k
      )
      n_at_k = ndcg_at_k(predicted_ranks, test_interactions, k=ndcg_k)
  
      p_at_k_insample = precision_at_k(
          predicted_ranks, train_interactions, k=precision_k
      )
      r_at_k_insample = recall_at_k(
          predicted_ranks, train_interactions, k=recall_k
      )
      n_at_k_insample = ndcg_at_k(
          predicted_ranks, train_interactions, k=ndcg_k
      )
  
      return (
          np.mean(r_at_k),
          np.mean(p_at_k),
          np.mean(n_at_k),
          np.mean(r_at_k_insample),
          np.mean(p_at_k_insample),
          np.mean(n_at_k_insample),
      )
  
file_path: tensorrec/tensorrec/eval.py
imports: import numpy
  import scipy.sparse
  from .tensorrec import TensorRec
label_desc: Use image node_id 8 for calling a global function with example usage: fit_and_eval(model, user_features, item_features, train_interactions, test_interactions, fit_kwargs, recall_k, precision_k, ndcg_k) and returns: np,  np,  np,  np,  np,  np