Beispiel #1
0
 def test_get_cohens_d_scores_zero_robust(self):
     corpus = build_hamlet_jz_corpus()
     corpus._X[1, :] = 0
     np.testing.assert_almost_equal(
         CohensD(corpus).set_term_ranker(OncePerDocFrequencyRanker).
         set_categories('hamlet').get_scores()[:5],
         [-0.2303607, 0.8838835, 0.8838835, 0.8838835, 0.8838835])
Beispiel #2
0
 def test_get_cohens_d_scores(self):
     corpus = build_hamlet_jz_corpus()
     np.testing.assert_almost_equal(
         CohensD(corpus).set_term_ranker(OncePerDocFrequencyRanker).
         set_categories('hamlet').get_cohens_d_scores()[:9], [
             0., 0.8242361, 0.8242361, 1.4276187, 0.8242361, 0.8242361,
             0.8242361, 0.8242361, 0.5395892
         ])
 def test_get_cohens_d_score_df(self):
     corpus = build_hamlet_jz_corpus()
     columns = (CohensD(corpus)
                .set_term_ranker(OncePerDocFrequencyRanker)
                .set_categories('hamlet')
                .get_score_df().columns)
     self.assertEqual(set(columns), set(['cohens_d', 'cohens_d_se', 'cohens_d_z', 'cohens_d_p', 'hedges_r',
                                         'hedges_r_se', 'hedges_r_z', 'hedges_r_p', 'm1', 'm2']))
Beispiel #4
0
 def test_get_name(self):
     corpus = build_hamlet_jz_corpus()
     self.assertEqual(
         CohensD(corpus).set_categories('hamlet').get_name(), "Cohen's d")
Beispiel #5
0
 def test_get_cohens_d_scores(self):
     corpus = build_hamlet_jz_corpus()
     np.testing.assert_almost_equal(
         CohensD(corpus).set_term_ranker(OncePerDocFrequencyRanker).
         set_categories('hamlet').get_scores()[:5],
         [-0.2127981, 0.8164966, 0.8164966, 1.3669723, 0.8164966])
Beispiel #6
0
 def test_get_cohens_d_scores(self):
     corpus = build_hamlet_jz_corpus()
     np.testing.assert_almost_equal(
         CohensD(corpus).set_term_ranker(OncePerDocFrequencyRanker).
         set_categories('hamlet').get_scores()[:5],
         [-0.2884615, 0.625, 0.625, 0.9919727, 0.625])