code: def test_recommend_k_items(rating_true):
      train_set = cornac.data.Dataset.from_uir(
          rating_true.itertuples(index=False), seed=42
      )
      bpr = cornac.models.BPR(k=100, max_iter=10000, seed=42).fit(
          train_set
      )
  
      preds = predict_ranking(bpr, rating_true, remove_seen=False)
  
      n_users = len(rating_true["userID"].unique())
      n_items = len(rating_true["itemID"].unique())
      assert preds.shape[0] == n_users * n_items
  
      assert set(preds.columns) == {"userID", "itemID", "prediction"}
      assert preds["userID"].dtypes == rating_true["userID"].dtypes
      assert preds["itemID"].dtypes == rating_true["itemID"].dtypes
      # perfect ranking achieved
      assert 1e-10 > 1 - ndcg_at_k(rating_true, preds)
      assert 1e-10 > 1 - recall_at_k(rating_true, preds)
  
file_path: recommenders/tests/unit/recommenders/models/test_cornac_utils.py
imports: import pytest
  import pandas
  import cornac
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL
  from recommenders.models.cornac.cornac_utils import predict, predict_ranking
  from recommenders.evaluation.python_evaluation import mae, rmse, ndcg_at_k, recall_at_k
label_desc: Use image node_id 3 for calling a global function with example usage: test_recommend_k_items(rating_true) without return types