Example #1
0
        def argmin(col, lo, hi):

            cut = None

            if hi - lo > 2 * enough:

                l, r = Num(), Num()

                for i in range(lo, hi + 1):
                    r.num_inc(sorted_rows[i][col])

                best = r.standard_deviation

                for i in range(lo, hi + 1):

                    curr_val = sorted_rows[i][col]

                    l.num_inc(curr_val)
                    r.num_dec(curr_val)

                    if l.count >= enough and r.count >= enough:

                        tmp = l.num_xpect(r) * 1.05

                        if tmp < best:
                            cut, best = i, tmp

            return cut
Example #2
0
 def argmin(c, lo, hi):
     cut = None
     xl, xr = Num([]), Num([])
     yl, yr = Num([]), Num([])
     for i in range(lo, hi + 1):
         xr.num_inc(rows[i][c])
         yr.num_inc(rows[i][goal])
     bestx = xr.sd
     besty = yr.sd
     mu = yr.mu
     n = yr.n
     if (hi - lo > 2 * enough):
         for i in range(lo, hi + 1):
             x = rows[i][c]
             y = rows[i][goal]
             xl.num_inc(x)
             xr.num_dec(x)
             yl.num_inc(y)
             yr.num_dec(y)
             if xl.n >= enough and xr.n >= enough:
                 tmpx = Num.num_xpect(data, xl, xr) * param_margin
                 tmpy = Num.num_xpect(data, yl, yr) * param_margin
                 if tmpx < bestx and tmpy < besty:
                     cut, bestx, besty = i, tmpx, tmpy
     return cut, mu, n, besty
Example #3
0
 def argmin(c, lo, hi):
     cut = None
     if (hi-lo > 2*enough):
         l = Num([])
         r = Num([])
         for i in range(lo,hi+1):
             r.num_inc(rows[i][c])
         best = r.sd
         for i in range(lo,hi+1):
             x = rows[i][c]
             l.num_inc(x)
             r.num_dec(x)
             if l.n >= enough and r.n >= enough:
                 tmp = Num.num_xpect(data, l, r) * param_margin
                 if tmp < best:
                     cut, best = i, tmp
     return cut
Example #4
0
        def argmin(col, lo, hi):

            cut = None

            xl, xr = Num(), Num()
            yl, yr = Num(), Num()

            for i in range(lo, hi + 1):
                xr.num_inc(self.data_rows[i][col])
                yr.num_inc(self.data_rows[i][goal])

            bestx = xr.standard_deviation
            besty = yr.standard_deviation

            mu = yr.mean

            if (hi - lo) > 2 * enough:

                for i in range(lo, hi + 1):

                    x = self.data_rows[i][col]
                    y = self.data_rows[i][goal]

                    xr.num_dec(x)
                    xl.num_inc(x)

                    yr.num_dec(y)
                    yl.num_inc(y)

                    if xl.count >= enough and xr.count >= enough:

                        tmpx = xl.num_xpect(xr) * 1.05
                        tmpy = yl.num_xpect(yr) * 1.05

                        if tmpx < bestx and tmpy < besty:
                            cut, bestx, besty = i, tmpx, tmpy

            return cut, mu, besty