Skip to content

Commit 809d597

Browse files
committed
Comments
1 parent 39d0f3a commit 809d597

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

analysis/parameter_tuning.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ def _find_candidate_parameters(
168168
linf_sum_bounds.append(
169169
_find_candidates_bins_max_values_subsample(
170170
hist.linf_sum_contributions_histogram, max_linf_candidates))
171-
# min_sum_per_partition_bounds = [0] * len(max_sum_per_partition_bounds)
172171
else: # n_sums > 1
173172
for i in range(n_sum_columns):
174173
linf_sum_bounds.append(
@@ -178,33 +177,37 @@ def _find_candidate_parameters(
178177

179178
# Linf COUNT and SUM bounds can have different number of elements, for
180179
# running Utility Analysis it is required that they have the same length.
181-
# Let us do padding with 0-th element.
182-
max_linf_size = 1 # max len of counts and sum bounds
180+
# Let us pad each to the max_length with 0-th element.
181+
max_linf_len = 1 # max len of counts and sum bounds
183182
if tune_count_linf:
184-
max_linf_size = len(linf_count_bounds)
183+
max_linf_len = len(linf_count_bounds)
185184
if tune_sum_linf:
186-
max_linf_size = max(max_linf_size, max(map(len, linf_sum_bounds)))
185+
max_linf_len = max(max_linf_len, max(map(len, linf_sum_bounds)))
187186

188187
if tune_count_linf:
189-
_pad_list(linf_count_bounds, max_linf_size)
188+
_pad_list(linf_count_bounds, max_linf_len)
190189
if tune_sum_linf:
191190
for a in linf_sum_bounds:
192-
_pad_list(a, max_linf_size)
191+
_pad_list(a, max_linf_len)
193192

194193
min_sum_per_partition = max_sum_per_partition = None
195194
if tune_sum_linf:
196-
max_linf_size = max(max_linf_size, len(linf_sum_bounds))
195+
max_linf_len = max(max_linf_len, len(linf_sum_bounds))
197196
n_sum_columns = hist.num_sum_histograms()
198197
if n_sum_columns == 1:
199198
max_sum_per_partition = linf_sum_bounds[0]
200199
min_sum_per_partition = [0] * len(max_sum_per_partition)
201-
else: # > 1
200+
else: # n_sum_columns > 1
202201
max_sum_per_partition = list(zip(*linf_sum_bounds))
203202
min_sum_per_partition = [
204203
(0,) * n_sum_columns for _ in range(len(max_sum_per_partition))
205204
]
206205

207-
l0_duplication = max_linf_size
206+
# Make cross-product of l0 and linf bounds. That is done by duplicating
207+
# each element of l0 bounds and by duplicating the whole arrays of linf
208+
# bounds. Example if l0_bound = [1,2] and linf_bounds = [3,4], then
209+
# l0_bounds will be [1,1,2,2] and linf_bounds will be [3,4,3,4].
210+
l0_duplication = max_linf_len
208211
linf_duplication = 1 if l0_bounds is None else len(l0_bounds)
209212
return analysis.MultiParameterConfiguration(
210213
max_partitions_contributed=_duplicate_each_element(

0 commit comments

Comments
 (0)