Exemple #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
Exemple #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
Exemple #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'])
Exemple #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'])
 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"])