Ejemplo n.º 1
0
 def test_optimal_spearman_is_borda(self):
     """ Check that Borda count and Spearman optimal rank aggregation returns the same output on the template matrix.
     """
     m_template = pd.read_csv('data/matrix.csv')
     m_template.index = m_template['index']
     m_template = m_template.drop('index', axis=1).rename_axis(None, axis=0)
     borda_rank = rk.rank(rk.borda(m_template), reverse=True)
     optimal_spearman_rank = rk.rank(
         rk.center(m_template, method='spearman'))
     print(borda_rank)
     print(optimal_spearman_rank)
     np.testing.assert_array_equal(borda_rank, optimal_spearman_rank)
Ejemplo n.º 2
0
def test_generator():
    print('Testing generator...')
    G = rk.Generator()
    R = [5, 4, 3, 2, 1]
    G.fit(R)
    print('Judgement matrix')
    m = G.sample(n=9)
    print(m)
    print('Score ranking')
    r = rk.score(m)
    print(r)
    distance = rk.dist(rk.rank(R), rk.rank(r))
    correlation = rk.corr(R, r)
    print('hamming distance: {}'.format(distance))
    print('kendall tau correlation: {}'.format(correlation))
    print('Uninominal ranking')
    r = rk.uninominal(m)
    print(r)
    distance = rk.dist(rk.rank(R), rk.rank(r))
    correlation = rk.corr(R, r)
    print('hamming distance: {}'.format(distance))
    print('kendall tau correlation: {}'.format(correlation))
Ejemplo n.º 3
0
 def test_rank(self):
     rank_M = np.array([[2., 3., 3.], [1., 1., 1.], [4., 2., 2.],
                        [3., 4., 4.], [5., 5., 5.]])
     np.testing.assert_array_equal(rk.rank(self.__class__.M), rank_M)