예제 #1
0
def test_classify_with_ds_diff_sizes():
    query = np.ones((10, 2))
    predictions = np.ones((5, 3))

    desknn_test = DESClustering(create_pool_classifiers())

    with pytest.raises(ValueError):
        desknn_test.classify_with_ds(query, predictions)
예제 #2
0
def test_classify_with_ds_diff_sizes():
    query = np.ones((10, 2))
    predictions = np.ones((5, 3))

    des_clustering = DESClustering()

    with pytest.raises(ValueError):
        des_clustering.classify_with_ds(query, predictions)
예제 #3
0
def test_classify_with_ds_single_sample():
    query = np.ones(2)
    predictions = np.array([0, 1, 0])

    desknn_test = DESClustering(create_pool_classifiers())
    desknn_test.select = MagicMock(return_value=np.array([[0, 2]]))
    result = desknn_test.classify_with_ds(query, predictions)
    assert np.allclose(result, 0)
예제 #4
0
def test_classify_instance():
    query = np.ones((1, 2))
    clustering_test = DESClustering(create_pool_classifiers() * 4, k=2)
    clustering_test.select = MagicMock(return_value=[0, 1, 2, 3, 5, 6, 7, 9])

    predictions = []
    for clf in clustering_test.pool_classifiers:
        predictions.append(clf.predict(query)[0])

    predicted = clustering_test.classify_with_ds(query, np.array(predictions))
    assert predicted == 0