Beispiel #1
0
def test_local_block_cosine_thresh_binary():
    e = expected_cosine_sim[[0, 1], :]
    e = e >= 0.9
    assert allclose(
        similarity_sparse_block(a1, [0, 1],
                                thresh=0.9,
                                binary=True,
                                metric='cosine').todense(), e)
Beispiel #2
0
def test_local_block_custom():
    assert allclose(
        similarity_sparse_block(
            a1, [0, 1], thresh=0,
            metric=custom_cosine_matrix_similarity).todense(),
        expected_cosine_sim[[0, 1], :])
Beispiel #3
0
def test_local_block_cosine_thresh():
    e = expected_cosine_sim[[0, 1], :]
    e[e < 0.9] = 0
    assert allclose(
        similarity_sparse_block(a1, [0, 1], thresh=0.9,
                                metric='cosine').todense(), e)
Beispiel #4
0
def test_local_block_hamming():
    assert allclose(
        similarity_sparse_block(a2, [0, 1], thresh=0,
                                metric='hamming').todense(),
        array([[1.0, 0.5, 0.25], [0.5, 1.0, 0.75]]))