def test_all_classifiers_agree(): # 10 classifiers that return 1 pool_classifiers = [create_base_classifier(return_value=1)] * 10 ds = DS(pool_classifiers) x = np.ones((1, 10)) assert ds._all_classifier_agree(x)
def test_predict_proba_all_agree(): query = np.atleast_2d([1, 1]) ds_test = DS(create_pool_classifiers()) ds_test.fit(X_dsel_ex1, y_dsel_ex1) ds_test.dsel_scores = dsel_scores_ex1 ds_test._all_classifier_agree = MagicMock(return_value=True) proba = ds_test.predict_proba(query) assert np.isclose(proba, np.atleast_2d([0.61, 0.39])).all()
def test_not_all_classifiers_agree(): # 10 classifiers that return 1, and one that returns 2 pool_classifiers = [create_base_classifier(return_value=1)] * 10 pool_classifiers.append(create_base_classifier(return_value=2)) ds = DS(pool_classifiers) x = np.ones((1, 10)) assert not ds._all_classifier_agree(x)
def test_all_classifiers_agree(): # 10 classifiers that return 1 predictions = np.ones((1, 10)) assert np.all(DS._all_classifier_agree(predictions))
def test_not_all_classifiers_agree(): # 10 classifiers that return 1, and one that returns 2 predictions = np.ones((10, 11)) predictions[:, -1] = 2 assert not np.all(DS._all_classifier_agree(predictions))