Ejemplo n.º 1
0
def test_estimate_competence_ones():
    query = np.atleast_2d([1, 1])
    probabilistic_test = Probabilistic(create_pool_classifiers())
    probabilistic_test.distances = distances_ex1[0, 0:3]
    probabilistic_test.neighbors = [0, 2, 1]
    probabilistic_test.DFP_mask = np.ones(probabilistic_test.n_classifiers)
    probabilistic_test.C_src = np.ones((3, 3))
    competence = probabilistic_test.estimate_competence(query)
    assert (competence == 1.0).all()
Ejemplo n.º 2
0
def test_estimate_competence():

    query = np.atleast_2d([1, 1])
    probabilistic_test = Probabilistic(create_pool_classifiers())
    probabilistic_test.distances = [0.5, 1.0, 2.0]
    probabilistic_test.neighbors = [0, 1, 2]
    probabilistic_test.DFP_mask = np.ones(probabilistic_test.n_classifiers)

    probabilistic_test.C_src = np.array([[0.5, 0.2, 0.8], [1.0, 1.0, 1.0],
                                         [1.0, 0.6, 0.3]])

    competence = probabilistic_test.estimate_competence(query)
    assert np.allclose(competence, [0.665, 0.458, 0.855], atol=0.01)
Ejemplo n.º 3
0
def test_estimate_competence_batch():
    n_samples = 10
    query = np.ones((n_samples, 2))
    probabilistic_test = Probabilistic(create_pool_classifiers())
    probabilistic_test.distances = np.tile([0.5, 1.0, 2.0], (n_samples, 1))
    probabilistic_test.neighbors = np.tile([0, 1, 2], (n_samples, 1))
    probabilistic_test.DFP_mask = np.ones(
        (n_samples, probabilistic_test.n_classifiers))

    probabilistic_test.C_src = np.array([[0.5, 0.2, 0.8], [1.0, 1.0, 1.0],
                                         [1.0, 0.6, 0.3]])
    expected = np.tile([0.665, 0.458, 0.855], (n_samples, 1))
    competence = probabilistic_test.estimate_competence(query)
    assert np.allclose(competence, expected, atol=0.01)