8000 MAINT Adapt `PairwiseDistancesReduction` heuristic for `strategy="auto"` by jjerphan · Pull Request #24043 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

MAINT Adapt PairwiseDistancesReduction heuristic for strategy="auto" #24043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion sklearn/metrics/_pairwise_distances_reduction/_base.pyx.tp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,18 @@ cdef class PairwiseDistancesReduction{{name_suffix}}:
if strategy == 'auto':
# This is a simple heuristic whose constant for the
# comparison has been chosen based on experiments.
if 4 * self.chunk_size * self.effective_n_threads < self.n_samples_X:
# parallel_on_X has less synchronization overhead than
# parallel_on_Y and should therefore be used whenever
# n_samples_X is large enough to not starve any of the
# available hardware threads.
if self.n_samples_Y < self.n_samples_X:
# No point to even consider parallelizing on Y in this case. This
# is in particular important to do this on machines with a large
# number of hardware threads.
strategy = 'parallel_on_X'
elif 4 * self.chunk_size * self.effective_n_threads < self.n_samples_X:
# If Y is larger than X, but X is still large enough to allow for
# parallelism, we might still want to favor parallelizing on X.
strategy = 'parallel_on_X'
else:
strategy = 'parallel_on_Y'
Expand Down
0