Ejemplo n.º 1
0
def test_estimate_competence_ones():
    query = np.atleast_2d([1, 1])
    probabilistic_test = BaseProbabilistic(create_pool_classifiers())
    probabilistic_test.k_ = 7

    distances = distances_ex1[0, 0:3].reshape(1, -1)
    neighbors = np.array([[0, 2, 1]])
    probabilistic_test.C_src_ = np.ones((3, 3))
    competence = probabilistic_test.estimate_competence(
        query, neighbors, distances)
    assert (competence == 1.0).all()
Ejemplo n.º 2
0
def test_estimate_competence_ones(example_estimate_competence):
    distances = example_estimate_competence[3]
    query = np.atleast_2d([1, 1])
    probabilistic_test = BaseProbabilistic()
    probabilistic_test.k_ = 7

    distances = distances[0, 0:3].reshape(1, -1)
    neighbors = np.array([[0, 2, 1]])
    probabilistic_test.C_src_ = np.ones((3, 3))
    competence = probabilistic_test.estimate_competence(neighbors,
                                                        distances)
    assert (competence == 1.0).all()
Ejemplo n.º 3
0
def test_estimate_competence_zeros(example_estimate_competence):
    distances = example_estimate_competence[3]
    query = np.atleast_2d([1, 1])
    probabilistic_test = BaseProbabilistic()
    probabilistic_test.k_ = 7

    distances = distances[0, 0:3].reshape(1, -1)
    neighbors = np.array([[0, 2, 1]])
    probabilistic_test.C_src_ = np.zeros((3, 3))
    competence = probabilistic_test.estimate_competence(
        competence_region=neighbors,
        distances=distances)
    assert np.sum(competence) == 0.0
Ejemplo n.º 4
0
def test_estimate_competence_batch():
    n_samples = 10
    query = np.ones((n_samples, 2))
    probabilistic_test = BaseProbabilistic()
    probabilistic_test.k_ = 7
    distances = np.tile([0.5, 1.0, 2.0], (n_samples, 1))
    neighbors = np.tile([0, 1, 2], (n_samples, 1))

    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(
        competence_region=neighbors,
        distances=distances)
    assert np.allclose(competence, expected, atol=0.01)