def test_select_best_batch(): competences = np.array([[1.0, 0.5, 0.5], [0.8, 0.9, 1.0], [0.0, 0.0, 0.15]]) expected = [0, 2, 2] pool_classifiers = create_pool_classifiers() dcs_test = DCS(pool_classifiers, selection_method='best') selected_clf = dcs_test.select(competences) assert np.array_equal(selected_clf, expected)
def test_select_all_batch(): competences = np.array([[1.0, 1.0, 0.5], [0.8, 0.9, 0.9], [0.15, 0.15, 0.15], [0.0, 0.0, 0.0]]) expected = np.array([[True, True, False], [False, True, True], [True, True, True], [True, True, True]]) pool_classifiers = create_pool_classifiers() dcs_test = DCS(pool_classifiers, selection_method='all') selected_clf = dcs_test.select(competences) assert np.array_equal(selected_clf, expected)
def test_select_diff(competences, expected): rng = np.random.RandomState(123456) pool_classifiers = create_pool_classifiers() dcs_test = DCS(pool_classifiers, selection_method='diff', diff_thresh=0.15, rng=rng) selected_clf = dcs_test.select(np.array(competences)) assert np.allclose(selected_clf, expected)
def test_select_random_batch(): competences = np.array([[0.5, 0.5, 0.5], [0.8, 0.9, 1.0], [0.0, 0.10, 0.0]]) expected = np.array([1, 2, 1]) rng = np.random.RandomState(123456) pool_classifiers = create_pool_classifiers() dcs_test = DCS(pool_classifiers, selection_method='random', rng=rng) selected_clf = dcs_test.select(competences) assert np.array_equal(selected_clf, expected)
def test_select_diff_batch(): competences = np.array([[1.0, 0.5, 0.5], [0.8, 0.9, 1.0], [0.0, 0.0, 0.15]]) expected = np.array([0, 2, 2]) rng = np.random.RandomState(123456) pool_classifiers = create_pool_classifiers() dcs_test = DCS(pool_classifiers, selection_method='diff', diff_thresh=0.15, rng=rng) selected_clf = dcs_test.select(competences) assert np.array_equal(selected_clf, expected)
def test_select_all(competences, expected): pool_classifiers = create_pool_classifiers() dcs_test = DCS(pool_classifiers, selection_method='all') selected_clf = dcs_test.select(np.array(competences)) assert np.allclose(selected_clf, expected)
def test_select_random(competences, expected): rng = np.random.RandomState(123456) pool_classifiers = create_pool_classifiers() dcs_test = DCS(pool_classifiers, selection_method='random', rng=rng) selected_clf = dcs_test.select(competences) assert selected_clf == expected
def test_select_all(competences, expected): pool_classifiers = create_pool_classifiers() dcs_test = DCS(pool_classifiers, selection_method='all') selected_clf = dcs_test.select(competences) assert selected_clf == expected