Пример #1
0
    def test_convert_to_block_df(self):
        a = np.array([[0, 0, 4],
                       [1, 0, 1],
                       [2, 0, 1],
                       [0, 1, 3],
                       [1, 1, 2],
                       [2, 1, 2],
                       [0, 2, 4],
                       [1, 2, 3],
                       [2, 2, 6],
                       [0, 3, 4],
                       [1, 3, 5],
                       [2, 3, 4],
                       [0, 4, 5],
                       [1, 4, 6],
                       [2, 4, 1],
                       [0, 5, 6],
                       [1, 5, 7],
                       [2, 5, 5],
                       [0, 6, 3],
                       [1, 6, 7],
                       [2, 6, 1]], dtype=np.float)

        result = sp.posthoc_nemenyi_friedman(a, y_col=2, group_col=1, block_col=0, melted=True)[0].values
        result2 = sp.posthoc_nemenyi_friedman(self.df_bn)[0].values
        self.assertTrue(np.allclose(result, result2))
Пример #2
0
    def test_posthoc_nemenyi_friedman(self):

        p_results = np.array([[-1., 0.9, 0.82163255, 0.9, 0.9, 0.21477876, 0.9],
                              [0.9, -1., 0.87719193, 0.9, 0.9, 0.25967965, 0.9],
                              [0.82163255, 0.87719193, -1., 0.9, 0.9, 0.9, 0.9],
                              [0.9, 0.9, 0.9, -1., 0.9, 0.87719193, 0.9],
                              [0.9, 0.9, 0.9, 0.9, -1., 0.87719193, 0.9],
                              [0.21477876, 0.25967965, 0.9, 0.87719193, 0.87719193, -1., 0.54381888],
                              [0.9, 0.9, 0.9, 0.9, 0.9, 0.54381888, -1.]])
        results = sp.posthoc_nemenyi_friedman(self.df_bn)
        self.assertTrue(np.allclose(results, p_results))
Пример #3
0
    def test_convert_to_block_df(self):
        a = np.array(
            [[0, 0, 4], [1, 0, 1], [2, 0, 1], [0, 1, 3], [1, 1, 2], [2, 1, 2],
             [0, 2, 4], [1, 2, 3], [2, 2, 6], [0, 3, 4], [1, 3, 5], [2, 3, 4],
             [0, 4, 5], [1, 4, 6], [2, 4, 1], [0, 5, 6], [1, 5, 7], [2, 5, 5],
             [0, 6, 3], [1, 6, 7], [2, 6, 1]],
            dtype=float)
        df_a = DataFrame(a, columns=['blk_col', 'grp_col', 'y_col'])

        result = sp.posthoc_nemenyi_friedman(a,
                                             y_col=2,
                                             group_col=1,
                                             block_col=0,
                                             melted=True)[0].values
        result2 = sp.posthoc_nemenyi_friedman(self.df_bn)[0].values
        result3 = sp.posthoc_nemenyi_friedman(df_a,
                                              y_col='y_col',
                                              group_col='grp_col',
                                              block_col='blk_col',
                                              melted=True)[0].values
        self.assertTrue(np.allclose(result, result2))
        self.assertTrue(np.allclose(result, result3))
        self.assertTrue(np.allclose(result2, result3))