Exemple #1
0
def test_clustered_subset_separation():
    """[Base] SubsetIndex: test the array shape on generation."""
    classes = cl_2.predict(X)
    for partition in ClusteredSubsetIndex(
        cl_2, 2, 2, X=X).partition(as_array=True):
        pc = np.unique(classes[partition])
        assert len(pc) == 1
Exemple #2
0
def test_clustered_subset_partition():
    """[Base] ClusteredSubsetIndex: test partition indexing on tuples."""
    parts = list()
    for part in ClusteredSubsetIndex(cl, X=X).partition():
        parts.append(part)

    assert parts == [[(0, 2)], [(2, 5)]]
Exemple #3
0
def test_clustered_subset_tuple_shape():
    """[Base] ClusteredSubsetIndex: test the tuple shape on generation."""
    tup = [(tri, tei)
           for tri, tei in ClusteredSubsetIndex(cl, 2, 2).generate(X)]

    assert tup == [([(0, 1)], [(1, 5)]), ([(1, 2)], [(0, 1), (2, 5)]),
                   ([(2, 4)], [(0, 2), (4, 5)]), ([(4, 5)], [(0, 4)])]
Exemple #4
0
def test_clustered_subset_partition_array():
    """[Base] ClusteredSubsetIndex: test partition indexing on arrays."""
    parts = list()
    for part in ClusteredSubsetIndex(cl, X=X).partition(as_array=True):
        parts.append(part)

    np.testing.assert_array_equal(parts[0], np.array([0, 1]))
    np.testing.assert_array_equal(parts[1], np.array([2, 3, 4]))
Exemple #5
0
def test_clustered_subset_array_shape():
    """[Base] ClusteredSubsetIndex: test the array shape on generation."""
    t = list()
    e = list()
    for tri, tei in ClusteredSubsetIndex(cl,
                                         2, 2, X=X).generate(as_array=True):
        t.append(tri.tolist())
        e.append(tei.tolist())

    assert t == [[0], [1], [2, 3], [4]]
    assert e == [[1, 2, 3, 4], [0, 2, 3, 4], [0, 1, 4], [0, 1, 2, 3]]