Exemplo n.º 1
0
def test_classify_with_ds_diff_sizes():
    query = np.ones((10, 2))
    predictions = np.ones((5, 3))

    clf1 = create_base_classifier(np.array([1, 0, 1, 0, 0, 0, 0]))
    clf2 = create_base_classifier(np.array([1, 0, 0, 0, 1, 0, 0]))
    clf3 = create_base_classifier(np.array([0, 0, 1, 0, 1, 1, 0]))

    pool_classifiers = [clf1, clf2, clf3]

    desknn_test = DESKNN(pool_classifiers)

    with pytest.raises(ValueError):
        desknn_test.classify_with_ds(query, predictions)
Exemplo n.º 2
0
def test_classify_with_ds_single_sample():
    query = np.ones(2)
    predictions = np.array([0, 1, 0])

    clf1 = create_base_classifier(np.array([1, 0, 1, 0, 0, 0, 0]))
    clf2 = create_base_classifier(np.array([1, 0, 0, 0, 1, 0, 0]))
    clf3 = create_base_classifier(np.array([0, 0, 1, 0, 1, 1, 0]))

    pool_classifiers = [clf1, clf2, clf3]

    desknn_test = DESKNN(pool_classifiers)
    desknn_test.estimate_competence = MagicMock(
        return_value=(np.ones(3), np.ones(3)))
    desknn_test.select = MagicMock(return_value=np.array([[0, 2]]))
    result = desknn_test.classify_with_ds(query, predictions)
    assert np.allclose(result, 0)