示例#1
0
def test_estimate_competence_woods(index, expected):
    lca_test = LCA(create_pool_classifiers())
    lca_test.processed_dsel = dsel_processed_ex1
    lca_test.neighbors = neighbors_ex1[index, :]
    lca_test.distances = distances_ex1[index, :]
    lca_test.DFP_mask = [1, 1, 1]
    lca_test.DSEL_target = y_dsel_ex1
    query = np.array([1, 1])
    competences = lca_test.estimate_competence(query.reshape(1, -1))
    assert np.isclose(competences, expected).all()
示例#2
0
def test_estimate_competence_diff_target(index):
    query = np.array([1, 1])

    lca = LCA(create_pool_classifiers())

    lca.processed_dsel = dsel_processed_ex1
    lca.DSEL_target = np.ones(15, dtype=int) * 3

    lca.neighbors = neighbors_ex1[index, :]
    lca.distances = distances_ex1[index, :]
    lca.DFP_mask = [1, 1, 1]

    expected = [0.0, 0.0, 0.0]

    competences = lca.estimate_competence(query.reshape(1, -1))
    assert np.isclose(competences, expected).all()
示例#3
0
def test_estimate_competence_woods(index, expected):
    lca_test = LCA(create_pool_classifiers())
    lca_test.processed_dsel = dsel_processed_ex1
    lca_test.neighbors = neighbors_ex1[index, :]
    lca_test.distances = distances_ex1[index, :]
    lca_test.DFP_mask = [1, 1, 1]
    lca_test.DSEL_target = y_dsel_ex1

    query = np.atleast_2d([1, 1])

    predictions = []
    for clf in lca_test.pool_classifiers:
        predictions.append(clf.predict(query)[0])
    competences = lca_test.estimate_competence(query, predictions=np.array(predictions))

    assert np.allclose(competences, expected)
示例#4
0
def test_estimate_competence_diff_target(index):
    lca_test = LCA(create_pool_classifiers())
    lca_test.processed_dsel = dsel_processed_ex1
    lca_test.DSEL_target = np.ones(15, dtype=int) * 3
    lca_test.neighbors = neighbors_ex1[index, :]
    lca_test.distances = distances_ex1[index, :]
    lca_test.DFP_mask = [1, 1, 1]

    query = np.atleast_2d([1, 1])
    expected = [0.0, 0.0, 0.0]

    predictions = []
    for clf in lca_test.pool_classifiers:
        predictions.append(clf.predict(query)[0])
    competences = lca_test.estimate_competence(query, predictions=np.array(predictions))

    assert np.isclose(competences, expected).all()
示例#5
0
def test_estimate_competence_batch():
    expected = np.array([[0.75000000,  0.66666667,  0.75000000],
                         [0.80000000, 1.00000000, 0.80000000],
                         [1.00000000, 0.60000000, 0.50000000]])
    lca_test = LCA(create_pool_classifiers())
    lca_test.processed_dsel = dsel_processed_ex1
    lca_test.neighbors = neighbors_ex1
    lca_test.distances = distances_ex1
    lca_test.DFP_mask = np.ones((3, 3))
    lca_test.DSEL_target = y_dsel_ex1

    query = np.ones((3, 2))

    predictions = []
    for clf in lca_test.pool_classifiers:
        predictions.append(clf.predict(query)[0])
    competences = lca_test.estimate_competence(query, predictions=np.array(predictions))

    assert np.isclose(competences, expected).all()