code: def test_uu_train():
      algo = knn.UserUser(30)
      ret = algo.fit(ml_ratings)
      assert ret is algo
  
      # it should have computed correct means
      umeans = ml_ratings.groupby("user").rating.mean()
      mlmeans = pd.Series(
          algo.user_means_, index=algo.user_index_, name="mean"
      )
      umeans, mlmeans = umeans.align(mlmeans)
      assert mlmeans.values == approx(umeans.values)
  
      # we should be able to reconstruct rating values
      uir = ml_ratings.set_index(["user", "item"]).rating
      r_items = algo.transpose_matrix_.rowinds()
      ui_rbdf = pd.DataFrame(
          {
              "user": algo.user_index_[algo.transpose_matrix_.colinds],
              "item": algo.item_index_[r_items],
              "nrating": algo.transpose_matrix_.values,
          }
      ).set_index(["user", "item"])
      ui_rbdf = ui_rbdf.join(mlmeans)
      ui_rbdf["rating"] = ui_rbdf["nrating"] + ui_rbdf["mean"]
      ui_rbdf["orig_rating"] = uir
      assert ui_rbdf.rating.values == approx(ui_rbdf.orig_rating.values)
  
imports: from lenskit.algorithms import Recommender
  import lenskit.algorithms.user_knn
  from lenskit.util import clone
  from pathlib import Path
  import logging
  import pickle
  import pandas
  import numpy
  from scipy.sparse import linalg
  from pytest import approx, mark
  import lenskit.util.test
label_desc: Use image node_id 5 for calling a global function with example usage: test_uu_train() without return types