### Question:
BiasItemScorer extends AbstractItemScorer { @Override public Result score(long user, long item) { return Results.create(item, model.getIntercept() + model.getUserBias(user) + model.getItemBias(item)); } @Inject  BiasItemScorer(BiasModel bias); @Override Result score(long user, long item); @Nonnull @Override Map<Long, Double> score(long user, @Nonnull Collection<Long> items); @Nonnull @Override ResultMap scoreWithDetails(long user, @Nonnull Collection<Long> items);  }### Answer:
@Test public void testGlobalMeanBias() { config.bind(BiasModel.class).to(GlobalBiasModel.class); ItemScorer pred = LenskitRecommender.build(config, dao).getItemScorer(); assertThat(pred, notNullValue()); Result score = pred.score(10L, 2L); assertThat(score.getScore(), closeTo(RATINGS_DAT_MEAN, 0.00001)); }
@Test public void testUserMeanBaseline() { config.bind(BiasModel.class).to(UserBiasModel.class); ItemScorer pred = LenskitRecommender.build(config, dao).getItemScorer(); assertThat(pred, notNullValue()); assertThat(pred.score(8, 4).getScore(), closeTo(4.5, 0.001)); assertThat(pred.score(8, 10).getScore(), closeTo(4.5, 0.001)); assertThat(pred.score(10, 10).getScore(), closeTo(RATINGS_DAT_MEAN, 0.001)); }
@Test public void testItemMeanBaseline() { config.bind(BiasModel.class).to(ItemBiasModel.class); ItemScorer pred = LenskitRecommender.build(config, dao).getItemScorer(); assertThat(pred, notNullValue()); assertThat(pred.score(10, 2).getScore(), closeTo(RATINGS_DAT_MEAN, 0.001)); assertThat(pred.score(10, 5).getScore(), closeTo(3.0, 0.001)); }
@Test public void testUserItemMeanBaseline() { config.bind(BiasModel.class).to(UserItemBiasModel.class); ItemScorer pred = LenskitRecommender.build(config, dao).getItemScorer(); assertThat(pred, notNullValue()); assertThat(pred.score(8, 10).getScore(), closeTo(RATINGS_DAT_MEAN + 0.5, 0.001)); assertThat(pred.score(8, 5).getScore(), closeTo(3.5, 0.001)); assertThat(pred.score(28, 5).getScore(), closeTo(3, 0.001)); }
@Test public void testLiveItemMeanBaseline() { config.bind(BiasModel.class).to(LiveUserItemBiasModel.class); ItemScorer pred = LenskitRecommender.build(config, dao).getItemScorer(); assertThat(pred, notNullValue()); assertThat(pred.score(8, 10).getScore(), closeTo(RATINGS_DAT_MEAN + 0.5, 0.001)); assertThat(pred.score(8, 5).getScore(), closeTo(3.5, 0.001)); assertThat(pred.score(28, 5).getScore(), closeTo(3, 0.001)); }