示例#1
0
    def test_spearmans_rho(self):
        # test basic functionality with full agreement, missing annotations
        fa = self.full_agreement

        self.assertAlmostEqual(pmc.spearmans_rho(fa.annotations[:,0],
                                                 fa.annotations[:,1]),
                               1.0, 6)
示例#2
0
    def test_all_invalid(self):
        # behavior: all measures should return np.nan for a set of
        # annotations with no valid entry

        anno = self.invalid_test.annotations

        self.assertTrue(
            np.isnan(pma.scotts_pi(anno[:, 0], anno[:, 1], nclasses=4)))

        self.assertTrue(
            np.isnan(pma.cohens_kappa(anno[:, 0], anno[:, 1], nclasses=3)))

        self.assertTrue(
            np.isnan(
                pma.cohens_weighted_kappa(anno[:, 0], anno[:, 1], nclasses=5)))

        self.assertTrue(np.isnan(pma.fleiss_kappa(anno, nclasses=4)))

        self.assertTrue(np.isnan(pma.krippendorffs_alpha(anno, nclasses=7)))

        self.assertTrue(
            np.isnan(pmc.pearsons_rho(anno[:, 0], anno[:, 1], nclasses=4)))

        self.assertTrue(
            np.isnan(pmc.spearmans_rho(anno[:, 0], anno[:, 1], nclasses=4)))

        self.assertTrue(np.isnan(pmc.cronbachs_alpha(anno, nclasses=4)))
示例#3
0
    def test_all_invalid(self):
        # behavior: all measures should return np.nan for a set of
        # annotations with no valid entry

        anno = self.invalid_test.annotations

        self.assert_(
            np.isnan(pma.scotts_pi(anno[:,0], anno[:,1], nclasses=4))
        )

        self.assert_(
            np.isnan(pma.cohens_kappa(anno[:,0], anno[:,1], nclasses=3))
        )

        self.assert_(
            np.isnan(pma.cohens_weighted_kappa(anno[:,0], anno[:,1],
                                               nclasses=5))
        )

        self.assert_(
            np.isnan(pma.fleiss_kappa(anno, nclasses=4))
        )

        self.assert_(
            np.isnan(pma.krippendorffs_alpha(anno, nclasses=7))
        )

        self.assert_(
            np.isnan(pmc.pearsons_rho(anno[:,0], anno[:,1], nclasses=4))
        )

        self.assert_(
            np.isnan(pmc.spearmans_rho(anno[:,0], anno[:,1], nclasses=4))
        )

        self.assert_(
            np.isnan(pmc.cronbachs_alpha(anno, nclasses=4))
        )