code: def test_bias_train_ml_ratings():
      algo = Bias()
      ratings = ml_test.ratings
      algo.fit(ratings)
  
      assert algo.mean_ == approx(ratings.rating.mean())
      imeans_data = ratings.groupby("item").rating.mean()
      imeans_algo = algo.item_offsets_ + algo.mean_
      ares, data = imeans_algo.align(imeans_data)
      assert ares.values == approx(data.values)
  
      urates = ratings.set_index("user").loc[2].set_index("item").rating
      umean = (urates - imeans_data[urates.index]).mean()
      p = algo.predict_for_user(2, [10, 11, -1])
      assert len(p) == 3
      assert p.iloc[0] == approx(imeans_data.loc[10] + umean)
      assert p.iloc[1] == approx(imeans_data.loc[11] + umean)
      assert p.iloc[2] == approx(ratings.rating.mean() + umean)
  
imports: from lenskit.algorithms.bias import Bias
  from lenskit import util
  import logging
  import pickle
  import binpickle
  import pandas
  import numpy
  from pytest import approx, raises, mark
  from lenskit.util.test import ml_test
label_desc: Use image node_id 14 for calling a global function with example usage: test_bias_train_ml_ratings() without return types