code: def test_als_predict_for_new_users_with_new_ratings():
      n_users = 3
      n_items = 2
      new_u_id = -1
      ratings = lktu.ml_test.ratings
  
      np.random.seed(45)
      users = np.random.choice(ratings.user.unique(), n_users)
      items = np.random.choice(ratings.item.unique(), n_items)
  
      algo = als.BiasedMF(20, iterations=10, method="lu")
      algo.fit(ratings)
      _log.debug("Items: " + str(items))
  
      for u in users:
          _log.debug(f"user: {u}")
          preds = algo.predict_for_user(u, items)
  
          user_data = ratings[ratings.user == u]
  
          _log.debug(
              "user_features from fit: "
              + str(algo.user_features_[algo.user_index_.get_loc(u), :])
          )
  
          new_ratings = pd.Series(
              user_data.rating.to_numpy(), index=user_data.item
          )  # items as index and ratings as values
          new_preds = algo.predict_for_user(
              new_u_id, items, new_ratings
          )
  
          _log.debug("preds: " + str(preds.values))
          _log.debug("new_preds: " + str(new_preds.values))
          _log.debug("------------")
          assert new_preds.values == approx(preds.values, rel=9e-2)
  
imports: import logging
  import pickle
  from pickletools import dis
  from lenskit.algorithms import als
  from lenskit import util
  import pandas
  import numpy
  from seedbank import numpy_rng
  from pytest import approx, mark
  from lenskit.util import Stopwatch
  import lenskit.util.test
label_desc: Use image node_id 6 for calling a global function with example usage: test_als_predict_for_new_users_with_new_ratings() without return types