def test_select_random_classifier(): competences = np.random.rand(100) expected = np.where(competences > 0.25)[0] probabilistic_test = Probabilistic(create_pool_all_agree(1, 100)) probabilistic_test.n_classes = 4 indices = probabilistic_test.select(competences) assert np.array_equal(indices, expected)
def test_select_threshold(): competences = np.random.rand(100) expected = np.where(competences > 0.5)[0] probabilistic_test = Probabilistic(create_pool_all_agree(1, 100)) probabilistic_test.selection_threshold = 0.5 indices = probabilistic_test.select(competences) assert np.array_equal(indices, expected)
def test_select_all_ones(): competences = np.ones(100) probabilistic_test = Probabilistic(create_pool_all_agree(1, 100)) probabilistic_test.n_classes = 2 indices = probabilistic_test.select(competences) assert indices == list(range(100))
def test_select_all_zeros(): competences = np.zeros(100) probabilistic_test = Probabilistic(create_pool_all_agree(1, 100)) probabilistic_test.n_classes = 2 selected_matrix = probabilistic_test.select(competences) assert selected_matrix.all()