def test_rank_entities(self): bt = BradleyTerry() bt.fit(TRANSITIVE_DATA_INDEXED, 'result') asc_rank = bt.rank_entities() correct_asc_rank = ['D', 'C', 'B', 'A'] self.assertListEqual(asc_rank, correct_asc_rank) desc_rank = bt.rank_entities(ascending=False) correct_desc_rank = ['A', 'B', 'C', 'D'] self.assertListEqual(desc_rank, correct_desc_rank)
def test_predict(self): bt = BradleyTerry() bt.fit(TRANSITIVE_DATA_INDEXED, 'result') pred = bt.predict(INDEXED_DATA_NORESCOL) correct_pred = np.array([0, 0, 1, 0]) np.testing.assert_array_equal(pred, correct_pred)
def test_predict_choice(self): bt = BradleyTerry() bt.fit(TRANSITIVE_DATA_INDEXED, 'result') choice = bt.predict_choice(INDEXED_DATA_NORESCOL) correct_choice = np.array(['B', 'A', 'C', 'C']) np.testing.assert_array_equal(choice, correct_choice)