def __init__(self, shape_list, domain_shape, size, seed=9001, pretty_name='random range'): self.init_params = util.init_params_from_locals(locals()) self.shape_list = copy.deepcopy(shape_list) self.seed = seed self.pretty_name = pretty_name self._size = size prng = numpy.random.RandomState(seed) if shape_list == None: shapes = randomQueryShapes(domain_shape, prng) else: prng.shuffle(self.shape_list) shapes = itertools.cycle( self.shape_list) # infinite iterable over shapes in shape_list queries = [] for i in range(size): lb, ub = placeRandomly(next(shapes), domain_shape, prng) # seed must be None or repeats queries.append(ndRangeUnion().addRange(lb, ub, 1.0)) super(RandomRange, self).__init__(queries, domain_shape)
def __init__(self, index='DEFAULT1D', short_name='AHP*'): self.init_params = util.init_params_from_locals(locals()) self._vSEP = Lfunction[index]['vSEP'] self._vRatio = Lfunction[index]['vRatio'] self._vEta = Lfunction[index]['vEta'] self.short_name = short_name
def __init__(self, domain, stripe_dim, ratio, approx): self.init_params = util.init_params_from_locals(locals()) self.ratio = ratio self.domain = domain self.stripe_dim = stripe_dim self.approx = approx super().__init__()
def __init__(self, short_name="GreedyH"): self.init_params = util.init_params_from_locals(locals()) self._max_block_size = None self._partition_engine = None self._estimate_engine = greedyH.greedyH_engine() self.short_name = short_name
def __init__(self, domain_shape, ratio, approx, workload_based=False): self.init_params = util.init_params_from_locals(locals()) self.domain_shape = domain_shape self.ratio = ratio self.approx = approx self.workload_based = workload_based super().__init__()
def __init__(self, domain_shape, workload_based=False): self.init_params = util.init_params_from_locals(locals()) self.domain_shape = domain_shape self.workload_based = workload_based super().__init__() assert len(domain_shape) in [1, 2], "HB only works for 1D and 2D domains"
def __init__(self, fileName, reduce_to_dom_shape=None): self.init_params = util.init_params_from_locals(locals()) self.fname = fileName #assert nickname in filenameDict, 'Filename parameter not recognized: %s' % nickname hist = load(self.fname) super(DatasetFromFile, self).__init__(hist, reduce_to_dom_shape, None)
def __init__(self, domain_shape, eta, ratio, workload_based=False): self.init_params = util.init_params_from_locals(locals()) self.n = np.prod(domain_shape) self.eta = eta self.ratio = ratio self.workload_based = workload_based super().__init__()
def __init__(self, config): self.init_params = util.init_params_from_locals(locals()) self.config = config self._df = None self.hist = None self.edges = None
def __init__(self, data_scale, alpha=0.5, c=10, c2=5): self.init_params = util.init_params_from_locals(locals()) self.alpha = alpha self.c = c self.c2 = c2 self.data_scale = data_scale super().__init__()
def __init__(self, ratio=0.25, short_name='DAWA'): # set ratio to 0 if no partition needed => GREEDYH_LINEAR,else DAWA_LINEAR. self.init_params = util.init_params_from_locals(locals()) self._ratio = ratio self._partition_engine = l1partition.l1partition_approx_engine() self._estimate_engine = greedyH.greedyH_engine() self.short_name = short_name
def __init__(self, ratio, rounds, data_scale, domain_shape, total_noise_scale): self.init_params = util.init_params_from_locals(locals()) self.ratio = ratio self.rounds = rounds self.data_scale = data_scale self.domain_shape = domain_shape self.total_noise_scale = total_noise_scale super().__init__()
def __init__(self, ratio, rounds, data_scale, domain_shape, use_history): self.init_params = util.init_params_from_locals(locals()) self.ratio = ratio self.rounds = rounds self.data_scale = data_scale self.domain_shape = domain_shape self.use_history = use_history super().__init__()
def __init__(self, domain_shape, stripe_dim, ratio, rounds, approx): self.init_params = util.init_params_from_locals(locals()) self.domain_shape = domain_shape self.stripe_dim = stripe_dim self.ratio = ratio self.rounds = rounds self.approx = approx super().__init__()
def __init__(self, domain_shape, ratio, approx, workload_based=False): self.init_params = util.init_params_from_locals(locals()) self.ratio = ratio self.approx = approx self.domain_shape = domain_shape self.workload_based = workload_based super().__init__() assert len(domain_shape) in [1, 2], "DAWA only works for 1D and 2D domains"
def __init__(self, domain_shape_int, pretty_name='prefix 1D'): self.init_params = util.init_params_from_locals(locals()) self.pretty_name = pretty_name queries = [ ndRangeUnion().add1DRange(0, c, 1.0) for c in range(domain_shape_int) ] super(self.__class__, self).__init__(queries, (domain_shape_int, ))
def __init__(self, branch=2, granu=100): """Setup the branching factor and granularity in numerical search. branch(2) - the branching factor of the hierarchy granu(100) - the granularity in numerical search """ self.init_params = util.init_params_from_locals(locals()) self._branch = branch self._granu = granu
def __init__(self, df, bins, domains, normed=False, weights=None): self.init_params = util.init_params_from_locals(locals()) self.df = df self.bins = bins self.domains = domains self.normed = normed self.weights = weights self.hist = None self.edges = None
def __init__(self, domain_shape, weight=1.0, pretty_name='identity'): self.init_params = util.init_params_from_locals(locals()) self.weight = weight self.pretty_name = pretty_name if type(domain_shape) is int: domain_shape = (domain_shape, ) indexes = itertools.product(*[list(range(i)) for i in domain_shape ]) # generate index tuples queries = [ndRangeUnion().addRange(i, i, weight) for i in indexes] super(self.__class__, self).__init__(queries, domain_shape)
def __init__(self, ratio=0.5, max_block_size=None, short_name="DAWA"): """ c,c2 are the constant parameter controlling the number of cells in each level alpha is the ratio of budget split on the first level beside total budget""" self.init_params = util.init_params_from_locals(locals()) self._ratio = ratio self._max_block_size = max_block_size self._partition_engine = l1partition.l1partition_approx_engine() self._estimate_engine = greedyH.greedyH_engine() self.short_name = short_name
def __init__(self, domain_shape, k, pretty_name='k-way marginals'): self.init_params = util.init_params_from_locals(locals()) self.pretty_name = pretty_name if type(domain_shape) is int: domain_shape = (domain_shape, ) assert 0 <= k <= len(domain_shape), 'invalid k' self.k = k D = len(domain_shape) idents = [Identity.oneD(n) for n in domain_shape] totals = [Total(n) for n in domain_shape] workloads = [] for c in itertools.combinations(list(range(D)), k): oned = [idents[i] if i in c else totals[i] for i in range(D)] workloads.append(Kronecker(oned)) super(self.__class__, self).__init__(workloads)
def __init__(self, relation, nickname, normed=False, weights=None, reduce_to_dom_shape=None): self.init_params = util.init_params_from_locals(locals()) self.fname = nickname histogram = Histogram(relation.df, relation.bins, relation.domains, normed, weights).generate() self.statistics = relation.statistics() self.statistics.update(histogram.statistics()) if reduce_to_dom_shape != None: self.statistics['domain_valid'] = False else: self.statistics['domain_valid'] = True super(DatasetFromRelation, self).__init__(histogram.hist.copy(order='C'), reduce_to_dom_shape)
def __init__(self, domain_shape, prefix_axes=(0, ), pretty_name='prefix marginals'): self.init_params = util.init_params_from_locals(locals()) self.pretty_name = pretty_name self.prefix_axes = prefix_axes if type(domain_shape) is int: domain_shape = (domain_shape, ) if len(domain_shape) - len(prefix_axes) > min(prefix_axes): import warnings warnings.warn( 'It is not recommended to construct PrefixMarginals this way. Transpose the data so that the prefix workloads are on the last dimensions' ) oned = [] for i, n in enumerate(domain_shape): if i in self.prefix_axes: oned.append(Prefix1D(n)) else: oned.append(Identity.oneD(n) + Total(n)) super(self.__class__, self).__init__(oned)
def __init__(self, uniformity, dom_shape, scale, seed=None): ''' Generate synthetic data of varying uniformity uniformity: parameter in [0,1] where 1 produces perfectly uniform data, 0 is maximally non-uniform All cells set to zero except fraction equal to 'uniformity' value. All non-zero cells are set to same value, then shuffled randomly. ''' self.init_params = util.init_params_from_locals(locals()) self.u = uniformity assert 0 <= uniformity and uniformity <= 1 n = numpy.prod(dom_shape) # total domain size hist = numpy.zeros(n) num_nonzero = max(1, int(uniformity * n)) hist_value = util.old_div(scale, num_nonzero) hist[0:num_nonzero] = hist_value prng = numpy.random.RandomState(seed) prng.shuffle(hist) super(DatasetUniformityVaryingSynthetic, self).__init__(hist.reshape(dom_shape), reduce_to_domain_shape=None, dist=None)
def __init__(self, ratio=0.85, eta=0.35, short_name='AHP'): self.init_params = util.init_params_from_locals(locals()) self._ratio = ratio self._eta = eta self.short_name = short_name
def __init__(self, domain, impl='MM', stripe_dim=-1): self.init_params = util.init_params_from_locals(locals()) self.domain = domain self.impl = impl self.stripe_dim = stripe_dim super().__init__()
def __init__(self, domain, stripe_dim): self.init_params = util.init_params_from_locals(locals()) self.domain = domain self.stripe_dim = stripe_dim super().__init__()
def __init__(self, data_scale): self.init_params = util.init_params_from_locals(locals()) self.data_scale = data_scale super().__init__()
def __init__(self, eta, ratio, workload_based=False): self.init_params = util.init_params_from_locals(locals()) self.eta = eta self.ratio = ratio self.workload_based = workload_based super().__init__()
def __init__(self, theta, domain): self.init_params = util.init_params_from_locals(locals()) self.theta = theta self.domain = domain super().__init__()