MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / optimal_partitions

Function optimal_partitions

join/LSH/datasketch/lshensemble_partition.py:172–194  ·  view source on GitHub ↗

Compute the optimal partitions given a distribution of set sizes. Args: sizes (numpy.array): The complete domain of set sizes in ascending order. counts (numpy.array): The frequencies of all set sizes in the same order as `sizes`. num_part (int):

(sizes, counts, num_part)

Source from the content-addressed store, hash-verified

170
171
172def optimal_partitions(sizes, counts, num_part):
173 """Compute the optimal partitions given a distribution of set sizes.
174
175 Args:
176 sizes (numpy.array): The complete domain of set sizes in ascending
177 order.
178 counts (numpy.array): The frequencies of all set sizes in the same
179 order as `sizes`.
180 num_part (int): The number of partitions to create.
181
182 Returns:
183 list: A list of partitions in the form of `(lower, upper)` tuples,
184 where `lower` and `upper` are lower and upper bound (inclusive)
185 set sizes of each partition.
186 """
187 if num_part < 2:
188 return [(sizes[0], sizes[-1])]
189 if num_part >= len(sizes):
190 partitions = [(x, x) for x in sizes]
191 return partitions
192 nfps = _compute_nfps_real(counts, sizes)
193 partitions, _, _ = _compute_best_partitions(num_part, sizes, nfps)
194 return partitions

Callers 2

count_partitionMethod · 0.90
index_oldMethod · 0.90

Calls 2

_compute_nfps_realFunction · 0.85
_compute_best_partitionsFunction · 0.85

Tested by

no test coverage detected