def test_compute_rewards_duplicates(self): k = 3 choices = ['RF', 'SVM'] scores = [0.7, 0.8, 0.7, 0.1, 0.8, 0.7] selector = BestKReward(choices, k=k) rewards = selector.compute_rewards(scores) np.testing.assert_array_equal( np.sort(rewards), np.sort([np.nan, np.nan, np.nan, 0.7, 0.8, 0.8]))
def test_compute_rewards_lt_k(self): # Set-up selector = BestKReward(['RF', 'SVM'], k=3) # Run scores = [0.8, 0.9] rewards = selector.compute_rewards(scores) # Assert assert rewards == scores
def test_compute_rewards_gt_k(self): # Set-up selector = BestKReward(['RF', 'SVM'], k=3) # Run scores = [0.83, 0.8, 0.86, 0.9] rewards = selector.compute_rewards(scores) # Assert np.testing.assert_array_equal(rewards, [0.83, np.nan, 0.86, 0.9])
def test_compute_rewards_gt_k(self): # Set-up selector = BestKReward(['RF', 'SVM'], k=3) # Run scores = [0.83, 0.8, 0.86, 0.9] rewards = selector.compute_rewards(scores) # Assert assert rewards == [0.83, 0.0, 0.86, 0.9]