def test_rule_count_p_n5(self):
     df = pd.read_csv('tests/test_files/testfile_4.csv',
                      encoding='utf-8',
                      delimiter=';')
     l = Literal('Sex', 'in', 'Female')
     rule = Rule()
     rule.add_literal(l)
     ds = BitmapDataset(1, df)
     ds.delete_covered(ds.unmake_rule(rule))
     p, n = ds.count_p_n_rule(ds.unmake_rule(rule))
     self.assertEqual(0, p)
     self.assertEqual(0, n)
 def test_delete_not_covered_4(self):
     df = pd.read_csv('tests/test_files/testfile_4.csv',
                      encoding='utf-8',
                      delimiter=';')
     l = Literal('Sex', 'in', 'Male')
     rule = Rule()
     rule.add_literal(l)
     ds = BitmapDataset(1, df)
     len_before = ds.length()
     ds.delete_covered(ds.unmake_rule(rule))
     self.assertEqual(36, ds.length())
     ds.delete_not_covered(ds.unmake_rule(rule))
     len_after = ds.length()
     self.assertEqual(len_before - 64, len_after)
 def test_unmake_rule_2(self):
     df = pd.read_csv('tests/test_files/mushroom.csv',
                      encoding='utf-8',
                      delimiter=';')
     ds = BitmapDataset(0, df)
     rule = Rule()
     rule = ds.unmake_rule(rule)
     self.assertEqual("[]", str(rule))
 def test_rule_count_p_n4(self):
     df = pd.read_csv('tests/test_files/testfile_8.csv',
                      encoding='utf-8',
                      delimiter=';')
     rule = Rule()
     ds = BitmapDataset(1, df)
     p, n = ds.count_p_n_rule(ds.unmake_rule(rule))
     self.assertEqual(16, p)
     self.assertEqual(16, n)
 def test_delete_not_covered_1(self):
     df = pd.read_csv('tests/test_files/testfile_8.csv',
                      encoding='utf-8',
                      delimiter=';')
     rule = Rule()
     ds = BitmapDataset(1, df)
     len_before = ds.length()
     ds.delete_not_covered(ds.unmake_rule(rule))
     len_after = ds.length()
     self.assertEqual(0, len_after)
 def test_rule_count_p_n3(self):
     df = pd.read_csv('tests/test_files/testfile_8.csv',
                      encoding='utf-8',
                      delimiter=';')
     l = Literal('ClassOfSeat', 'in', '1st')
     rule = Rule()
     rule.add_literal(l)
     ds = BitmapDataset(1, df)
     p, n = ds.count_p_n_rule(ds.unmake_rule(rule))
     self.assertEqual(4, p)
     self.assertEqual(4, n)
 def test_delete_not_covered_3(self):
     df = pd.read_csv('tests/test_files/testfile_8.csv',
                      encoding='utf-8',
                      delimiter=';')
     l = Literal('ClassOfSeat', 'in', '1st')
     rule = Rule()
     rule.add_literal(l)
     ds = BitmapDataset(1, df)
     len_before = ds.length()
     ds.delete_not_covered(ds.unmake_rule(rule))
     len_after = ds.length()
     self.assertEqual(len_before - 24, len_after)
 def test_prune_rule_2(self):
     df = pd.read_csv('tests/test_files/mushroom.csv',
                      encoding='utf-8',
                      delimiter=';')
     ds = BitmapDataset(0, df)
     l = Literal('a5', 'in', ['c', 'f', 'm', 'p', 's', 'y'])
     rule = Rule()
     rule.add_literal(l)
     rule = ds.unmake_rule(rule)
     rule = ds.prune_rule(rule)
     rule = ds.make_rule(rule)
     self.assertEqual("a5 in ['c', 'f', 'm', 'p', 's', 'y']",
                      rule.to_string())
 def test_prune_rule_1(self):
     df = pd.read_csv('tests/test_files/testfile_3.csv',
                      encoding='utf-8',
                      delimiter=';')
     l = Literal('Sex', 'in', 'Female')
     l2 = Literal('Sex', 'in', 'Male')
     rule = Rule()
     rule.add_literal(l)
     rule.add_literal(l2)
     ds = BitmapDataset(1, df)
     rule = ds.prune_rule(ds.unmake_rule(rule))
     rule = ds.make_rule(rule)
     self.assertEqual("", rule.to_string())
 def test_unmake_rule_1(self):
     df = pd.read_csv('tests/test_files/mushroom.csv',
                      encoding='utf-8',
                      delimiter=';')
     ds = BitmapDataset(0, df)
     rule = Rule()
     l = Literal('a1', 'in', 'x')
     l2 = Literal('a3', 'in', 'g')
     l3 = Literal('a6', 'in', ['a', 'f'])
     rule.add_literal(l)
     rule.add_literal(l2)
     rule.add_literal(l3)
     rule = ds.unmake_rule(rule)
     self.assertEqual("[[0, 0], [2, 3], [5, 0], [5, 1]]", str(rule))