def create_feature_space_IG(n): a={} weight = {} ig, gr, si = textgain.compute('IG') sortedIG = sorted(ig,key=ig.__getitem__,reverse=True) k = sortedIG[:n] for j in range(0,len(k)): if k[j] not in a: a[k[j]] = len(a) weight[k[j]] = ig[k[j]] return [a,weight]
def create_feature_space_IG(n): a = {} weight = {} ig, gr, si = textgain.compute('IG') sortedIG = sorted(ig, key=ig.__getitem__, reverse=True) k = sortedIG[:n] for j in range(0, len(k)): if k[j] not in a: a[k[j]] = len(a) weight[k[j]] = ig[k[j]] return [a, weight]
def create_feature_space_IG(bi): a = {} ig, gr, si = textgain.compute('IG') sortedIG = sorted(ig, key=ig.__getitem__, reverse=True) ki = sortedIG[:8000] k = bi[:16000] k.extend(ki) print len(k) for j in range(0, len(k)): if k[j] not in a: a[k[j]] = len(a) return a
def create_feature_space_IG(bi): a={} ig, gr, si = textgain.compute('IG') sortedIG = sorted(ig,key=ig.__getitem__,reverse=True) ki = sortedIG[:8000] k = bi[:16000] k.extend(ki) print len(k) for j in range(0,len(k)): if k[j] not in a: a[k[j]] = len(a) return a