def test_multinomial_proportion_choice_model_default(self): choice_features = dict(min_normalizer=0) mnp_model = choice_model.MultinomialProportionalChoiceModel( choice_features=choice_features) mnp_model.score_documents(self._user_state, np.array([[0.8, 0.6], [0.6, 0.8]])) # The scores are the dot product between user features and doc features. self.assertAlmostEqual(mnp_model._scores[0], 1, delta=0.001) self.assertAlmostEqual(mnp_model._scores[1], 0.96, delta=0.001) self.assertEqual(mnp_model._score_no_click, 0)
def test_multinomial_proportion_min_normalizer(self): choice_features = dict(min_normalizer=0.5, no_click_mass=0.5) mnp_model = choice_model.MultinomialProportionalChoiceModel( choice_features=choice_features) mnp_model.score_documents(self._user_state, np.array([[0.8, 0.6], [0.6, 0.8]])) # The scores the dot product user features and doc features minus the # min_normalizer. self.assertAlmostEqual(mnp_model._scores[0], 0.5, delta=0.001) self.assertAlmostEqual(mnp_model._scores[1], 0.46, delta=0.001) self.assertAlmostEqual(mnp_model._score_no_click, 0, delta=0.001)