Esempio n. 1
0
def test_rank_scale_versus_scipy(A):
    data = A.value

    # rank the data all at once
    output = rank(data)

    # check each column versus scipy equivalent
    for i in range(data.shape[1]):
        feature = data[:, i]
        expected = rankdata(feature)
        assert np.allclose(expected, output[:, i])
Esempio n. 2
0
def spearman_pairwise(A):
    """
    Calculates the Spearman rank correlation
    coefficient between pairs of columns of
    the supplied matrix A (similar to
    pandas.DataFrame.corr(method='spearman').

    Ties are dealt with using the 'average'
    method, as described in rank_data.
    """
    assert A.ndim > 1
    assert A.shape[1] > 1

    A_rank = rank(A)
    return pearson_pairwise(A_rank)