예제 #1
0
def info(table, res_col):
    """ Calculates the entropy of the table _table_
        where res_col column = _res_col_.
    """
    s = 0 # sum
    for v in utils.deldup(table[res_col]):
        p = freq(table, res_col, v) / float(len(table[res_col]))
        s += p * math.log(p, 2)
    return -s
예제 #2
0
def info(table, res_col):
    """ Calculates the entropy of the table _table_
        where res_col column = _res_col_.
    """
    s = 0  # sum
    for v in utils.deldup(table[res_col]):
        p = freq(table, res_col, v) / float(len(table[res_col]))
        s += p * math.log(p, 2)
    return -s
예제 #3
0
 def test_deldup(self):
     testlist = ['yes', 'yes', 'yes', 'yes']
     self.assertEqual(utils.deldup(testlist), ['yes'])
     testlist = ['yes', 'no', 'yes', 'no']
     self.assertEqual(utils.deldup(testlist), ['yes', 'no'])
예제 #4
0
 def test_deldup(self):
     testlist = ['yes', 'yes', 'yes', 'yes']
     self.assertEqual(utils.deldup(testlist), ['yes'])
     testlist = ['yes', 'no', 'yes', 'no']
     self.assertEqual(utils.deldup(testlist), ['yes', 'no'])
예제 #5
0
 def test_deldup(self):
     testlist = ["yes", "yes", "yes", "yes"]
     self.assertEquals(utils.deldup(testlist), ["yes"])
     testlist = ["yes", "no", "yes", "no"]
     self.assertEquals(utils.deldup(testlist), ["yes", "no"])