code: def test_topn_big():
      ratings = lktu.ml_test.ratings
      users = ratings.user.unique()
      items = ratings.item.unique()
      user_items = ratings.set_index("user").item
  
      algo = basic.TopN(bias.Bias())
      a2 = algo.fit(ratings)
      assert a2 is algo
  
      # test 100 random users
      for u in np.random.choice(users, 100, False):
          recs = algo.recommend(u, 100)
          assert len(recs) == 100
          rated = user_items.loc[u]
          assert all(~recs["item"].isin(rated))
          unrated = np.setdiff1d(items, rated)
          scores = algo.predictor.predict_for_user(u, unrated)
          top = scores.nlargest(100)
          assert top.values == approx(recs.score.values)
  
file_path: lkpy/tests/test_topn_recs.py
imports: from lenskit.algorithms import basic
  from lenskit.algorithms import bias
  import pandas
  import numpy
  import lenskit.util.test
  from pytest import approx
label_desc: Use image node_id 3 for calling a global function with example usage: test_topn_big() without return types