コード例 #1
0
ファイル: sdtree.py プロジェクト: rahlk/FSS17-GroupV
 def __init__(self, t, yfun, pos, attr, val):
     num = NUM()
     self._t = t
     self._kids = []
     self.yfun = yfun
     self.pos = pos
     self.attr = attr
     self.val = val
     self.stats = num.updates(t.rows, yfun)
コード例 #2
0
def range_manager(t, x, cohen, m):
    DATA = NUM()
    control_r = dict()
    control_r['x'] = x
    control_r['cohen'] = cohen
    control_r['m'] = m
    control_r['size'] = len(t)
    control_r['ranges'] = []
    control_r = nextRange(control_r)
    control_r['num'] = DATA.updates(t, control_r['x'])
    control_r['hi'] = control_r['num'].hi
    control_r['enough'] = control_r['size']**control_r['m']
    control_r['epsilon'] = control_r['num'].sd * control_r['cohen']
    return control_r
コード例 #3
0
def contrasts(branches, better):
    result = ""
    for i, branch1 in enumerate(branches):
        out = []
        for j, branch2 in enumerate(branches):
            if i != j:
                num1 = branch1['branch'][-1]['_stats']
                num2 = branch2['branch'][-1]['_stats']
                if better(num2.mu, num1.mu):
                    if not NUM.same(num1, num2):
                        inc = delta(branch2['has'], branch1['has'])
                        if len(inc) > 0:
                            temp_out = {
                                'i': i,
                                'j': j,
                                'ninc': len(inc),
                                'muinc': num2.mu - num1.mu,
                                'inc': inc,
                                'branch1': branch1['has'],
                                'mu1': num1.mu,
                                'branch2': branch2['has'],
                                'mu2': num2.mu
                            }
                            out.append(temp_out)
        if len(out) > 0:
            tmp_result = "\n"
            sorted(out, key=lambda x: x['muinc'])
            tmp_result += "%s max mu  %s \n" % (i, out[0])
            sorted(out, key=lambda x: x['ninc'])
            tmp_result += "%s min inc %s \n" % (i, out[0])
        #else:
        #    tmp_result = "Empty out at i_%s \n" % i
        print(tmp_result)
        result += tmp_result
    return out, result
コード例 #4
0
ファイル: sdtree.py プロジェクト: rahlk/FSS17-GroupV
 def whatif(head, y):
     col = {"pos": head.pos, "what": head.txt, "nums": {}, "n": 0}
     for r in t.rows:
         x = r.cells[col["pos"]]
         if x != '?':
             col["n"] += 1
             if x not in col["nums"].keys():
                 col["nums"][x] = NUM()
             col["nums"][x].update(y(r))
     return {"key": xpect(col), "val": col}
コード例 #5
0
 def read_header(self, h_line):
     entries = self.remove_mis(h_line).split(",")
     for entry in entries:
         entry = entry.strip()
         if entry:
             self.header.header.append(entry)
     self.header.noc = len(self.header.header)
     for i in range(self.header.noc):
         cate = self.header.header[i][0]
         if cate == "?":
             self.header.ignore_cols.append(i)
             self.container.append(None)
         elif cate == "$" or cate == "<" or cate == ">":
             self.header.nums[str(i)] = NUM()
             self.container.append(NUM())
             if cate == "<" or cate == ">":
                 if cate == ">":
                     self.header.goals.append((i, 1))
                 else:
                     self.header.goals.append((i, -1))
         else:
             self.header.syms[str(i)] = SYM()
             self.container.append(SYM())
コード例 #6
0
def test():
    t, n = [], NUM()
    R = RANDOM()
    split = [0.2, 0.5]
    for i in range(1, 51):
        w = R.r()
        n.update(klass(w))
        t.append((w, klass(w)))
    print("\nWe have many unsupervised ranges.")
    for j, one in enumerate(RANGE.unsup_discret(t, x, 0, split)):
        print("x", j, one)
    print("\nWe have fewer supervised ranges.")
    for j, one in enumerate(SUPER_R.sup_discretize(t, x, y, True, True, split)):
        print("super", j, one)