code: def test_evaluate(self):
      next_item_eval = NextItemEvaluation.from_splits(
          train_data=self.data[:50],
          test_data=self.data[50:],
          fmt="USIT",
      )
      result = next_item_eval.evaluate(
          SPop(), [HitRatio(k=2), Recall(k=2)], user_based=False
      )
      self.assertEqual(
          result[0].metric_avg_results.get("HitRatio@2"), 0
      )
      self.assertEqual(result[0].metric_avg_results.get("Recall@2"), 0)
  
      next_item_eval = NextItemEvaluation.from_splits(
          train_data=self.data[:50],
          test_data=self.data[50:],
          fmt="USIT",
      )
      result = next_item_eval.evaluate(
          SPop(), [HitRatio(k=5), Recall(k=5)], user_based=True
      )
      self.assertEqual(
          result[0].metric_avg_results.get("HitRatio@5"), 2 / 3
      )
      self.assertEqual(
          result[0].metric_avg_results.get("Recall@5"), 2 / 3
      )
  
      next_item_eval = NextItemEvaluation.from_splits(
          train_data=self.data[:50],
          test_data=self.data[50:],
          fmt="USIT",
          mode="next",
      )
      result = next_item_eval.evaluate(
          SPop(), [HitRatio(k=2), Recall(k=2)], user_based=False
      )
  
      self.assertEqual(
          result[0].metric_avg_results.get("HitRatio@2"), 1 / 8
      )
      self.assertEqual(
          result[0].metric_avg_results.get("Recall@2"), 1 / 8
      )
  
      next_item_eval = NextItemEvaluation.from_splits(
          train_data=self.data[:50],
          test_data=self.data[50:],
          fmt="USIT",
          mode="next",
      )
      result = next_item_eval.evaluate(
          SPop(), [HitRatio(k=5), Recall(k=5)], user_based=True
      )
      self.assertEqual(
          result[0].metric_avg_results.get("HitRatio@5"), 3 / 4
      )
      self.assertEqual(
          result[0].metric_avg_results.get("Recall@5"), 3 / 4
      )
  
file_path: cornac/tests/cornac/eval_methods/test_next_item_evaluation.py
imports: import unittest
  from cornac.eval_methods import NextItemEvaluation
  from cornac.data import Reader
  from cornac.models import SPop
  from cornac.metrics import HitRatio, Recall
label_desc: Use image node_id 3 for calling the TestNextItemEvaluation obj's underlying member method code with example usage: obj.test_evaluate() without return types