code: def test_predict_user(mlb):
      uid = 5
      urates = mlb.ratings[mlb.ratings.user == uid]
  
      test_rated = urates.item.sample(5)
      unrated = np.setdiff1d(
          mlb.ratings.item.unique(), urates.item.values
      )
      test_unrated = np.random.choice(unrated, 10, replace=False)
      test_items = pd.concat([test_rated, pd.Series(test_unrated)])
  
      tf = pd.DataFrame({"user": uid, "item": test_items})
      res = lkb.predict(mlb.algo, tf)
  
      assert len(res) == 15
      assert set(res.columns) == set(["user", "item", "prediction"])
      assert all(res.user == uid)
      assert set(res.item) == set(test_items)
  
      # did we get the right predictions?
      preds = res.set_index(["user", "item"])
      preds["rating"] = mlb.algo.mean_
      preds["rating"] += mlb.algo.item_offsets_
      preds["rating"] += mlb.algo.user_offsets_.loc[uid]
      assert preds.prediction.values == pytest.approx(
          preds.rating.values
      )
  
file_path: lkpy/tests/test_batch_predict.py
imports: import pytest
  import logging
  from collections import namedtuple
  import pandas
  import numpy
  import lenskit.util.test
  from lenskit.algorithms.bias import Bias
  import lenskit.batch
label_desc: Use image node_id 3 for calling a global function with example usage: test_predict_user(mlb) without return types