Beispiel #1
0
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)
Beispiel #2
0
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()
Beispiel #3
0
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)
Beispiel #4
0
def test_all_classifiers_agree():
    # 10 classifiers that return 1
    predictions = np.ones((1, 10))

    assert np.all(DS._all_classifier_agree(predictions))
Beispiel #5
0
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))