code: def test_als_batch_accuracy():
      import lenskit.crossfold as xf
      import lenskit.metrics.predict as pm
  
      ratings = lktu.ml100k.ratings
  
      lu_algo = als.BiasedMF(25, iterations=20, damping=5, method="lu")
      cd_algo = als.BiasedMF(25, iterations=25, damping=5, method="cd")
      # algo = bias.Fallback(svd_algo, bias.Bias(damping=5))
  
      def eval(train, test):
          _log.info("training LU")
          lu_algo.fit(train)
          _log.info("training CD")
          cd_algo.fit(train)
          _log.info("testing %d users", test.user.nunique())
          return test.assign(
              lu_pred=lu_algo.predict(test),
              cd_pred=cd_algo.predict(test),
          )
  
      folds = xf.partition_users(ratings, 5, xf.SampleFrac(0.2))
      preds = pd.concat(eval(train, test) for (train, test) in folds)
      preds["abs_diff"] = np.abs(preds.lu_pred - preds.cd_pred)
      _log.info(
          "predictions:\n%s",
          preds.sort_values("abs_diff", ascending=False),
      )
      _log.info("diff summary:\n%s", preds.abs_diff.describe())
  
      lu_mae = pm.mae(preds.lu_pred, preds.rating)
      assert lu_mae == approx(0.73, abs=0.045)
      cd_mae = pm.mae(preds.cd_pred, preds.rating)
      assert cd_mae == approx(0.73, abs=0.045)
  
      user_rmse = preds.groupby("user").apply(
          lambda df: pm.rmse(df.lu_pred, df.rating)
      )
      assert user_rmse.mean() == approx(0.94, abs=0.05)
      user_rmse = preds.groupby("user").apply(
          lambda df: pm.rmse(df.cd_pred, df.rating)
      )
      assert user_rmse.mean() == approx(0.94, abs=0.05)
  
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 14 for calling a global function with example usage: test_als_batch_accuracy() and returns: test