Ejemplo n.º 1
0
 def argmin(self, c, lo, hi):
     cut = None
     if hi - lo > self.enough:
         l, r = Num([]), Num([])
         for i in range(lo, hi + 1):
             r.numInc(float(self.rows[i][c]))
         best = r.sd
         for i in range(lo, hi + 1):
             x = float(self.rows[i][c])
             l.numInc(x)
             r.numDec(x)
             if l.n >= self.enough and r.n >= self.enough:
                 tmp = Num.numXpect(l, r) * Vars.unsuper['margin']
                 if tmp < best:
                     cut, best = i, tmp
     return cut
    def argmin(c, lo, hi):
        cut = None
        if ((hi - lo) > 2 * enough):
            l = Num([])
            r = Num([])
            for i in range(lo, hi + 1):
                r.numInc(rows[i][c])
            best = r.sd
            for i in range(lo, hi + 1):
                x = rows[i][c]
                l.numInc(x)
                r.numDec(x)

                if l.n >= enough and r.n >= enough:
                    tmp = Num.numXpect(data, l, r) * 1.05
                    if tmp < best:
                        cut = i
                        best = tmp
        return cut