def run(self): init = noop() data = init.apply(self.data) value = self.qfn.run(init.apply(data)) startTime = datetime.datetime.now() for g, p in zip(self.generator, self.params): argvalue = sys.maxsize argmax = noop() for instance in p: gen = g(data, list([instance])) xform = gen.bbrun() newValue = self.qfn.run(xform.apply(data)) if newValue < argvalue: value = newValue argmax = xform init = argmax + init self.search_stats['runtime'] = (datetime.datetime.now() - startTime).total_seconds() return (value, init, data)
def run(self): init = noop() data = init.apply(self.data) value = self.qfn.run(init.apply(data)) startTime = datetime.datetime.now() for element in itertools.product(*self.params): argmax = noop() for i in range(0, len(self.params)): g = self.generator[i](data, list([element[i]])) t = g.bbrun() prior = self.qfn.run(argmax.apply(data)) argmax = t + argmax post = self.qfn.run(argmax.apply(data)) if post > prior: argmax = t newValue = self.qfn.run(argmax.apply(data)) if newValue < value: value = newValue init = argmax self.search_stats['runtime'] = (datetime.datetime.now() - startTime).total_seconds() return (value, init, data)
def _getAttribute(self, attr): for sim, thresh in self.generatorParams: xform = noop() for tup in self._attrPairIterator(attr): if sim(tup[0], tup[0]) < thresh: xform = satransform(attr, tup[0], tup[1], EQ) + xform yield xform
def run(self): init = noop() data = init.apply(self.data) startTime = datetime.datetime.now() for i in range(self.maxDepth): value, xform = self._runIter(data, init) data = xform.apply(data) init = xform + init if value == 0: break self.search_stats['runtime'] = (datetime.datetime.now() - startTime).total_seconds() return (value, xform, data)
def _runIter(self, data, init=noop()): xform = init value = self.qfn.run(xform.apply(data)) for g, p in zip(self.generator, self.params): gen = g(data, p) if value == 0: break for score, newXform in gen.score(self.qfn, xform): if value == 0: break if score < value: xform = newXform value = score return (value, xform)
def _getAttribute(self, attr): for sszie, hsize in self.generatorParams: dup = {} hf = self.genFamily(1) xform = noop() for s in self._attrVals(attr): v = self.minHash(self.shingle(s,2), hf) if v not in dup: dup[v] = [] dup[v].append(s) for v in dup: if len( dup[v]) > 1: for s in dup[v]: xform = satransform(attr, s, dup[v][0], EQ) + xform yield xform
def bbrun(self): xform = noop() for newXform in self.get(): xform = newXform + xform return xform