Example #1
0
def test_predict_proba_instance_all(competences, expected):
    query = np.array([-1, 1])
    pool_classifiers = create_pool_classifiers()
    dcs_test = DCS(pool_classifiers, selection_method='all')
    dcs_test.n_classes = 2

    dcs_test.estimate_competence = MagicMock(return_value=competences)
    predicted_proba = dcs_test.predict_proba_instance(query)
    assert np.isclose(predicted_proba, expected).all()
Example #2
0
def test_predict_proba_instance():
    query = np.array([-1, 1])
    pool_classifiers = create_pool_classifiers()
    dcs_test = DCS(pool_classifiers)
    dcs_test.n_classes = 2

    competences = np.random.rand(dcs_test.n_classifiers)

    dcs_test.estimate_competence = MagicMock(return_value=competences)
    expected = pool_classifiers[np.argmax(competences)].predict_proba(query)

    predicted_proba = dcs_test.predict_proba_instance(query)
    assert np.array_equal(predicted_proba, expected)