[MRG] Changed implementation of Birch.predict to use pairwise_distances…#16149
Conversation
…_chunked in order to reduce memory footprint (scikit-learn#16027)
|
Benchmark script + output performance_16027.txt Bellow examples of running the benchmark on several sample sizes. Is there a location in the scikit-learn source code tree where I can put the performance test? |
jeremiedbb
left a comment
There was a problem hiding this comment.
Thanks for the PR @alexshacked. I don't think we need to store the performance tests in the codebase. Your reports in the PR discussion should be enough.
jeremiedbb
left a comment
There was a problem hiding this comment.
lgtm. Thanks @alexshacked !
|
You're right @jeremiedbb. On large input size, the increase in memory doesen't go beyond the 1GB chunk size |
|
Should we be passing Y_norm_squared as a parameter for euclidean_distances to avoid recomputing them? |
|
Right @jnothman. I get it. No need to calculate YY for each chunk. |
… when processing is not parallel (scikit-learn#16027)
| self._check_fit(X) | ||
| reduced_distance = safe_sparse_dot(X, self.subcluster_centers_.T) | ||
| reduced_distance *= -2 | ||
| reduced_distance += self._subcluster_norms |
There was a problem hiding this comment.
I meant that we could pass these sub cluster norms into pairwise_distances_argmin
There was a problem hiding this comment.
Something like this ?
kwargs = { 'Y_norm_squared': self._subcluster_norms}
return self.subcluster_labels_[
pairwise_distances_argmin(X, self.subcluster_centers_, metric_kwargs = kwargs)
]
…ough pairwise_distances_argmin (scikit-learn#16027)
|
@jnothman _subcluster_norms is passed to pairwise_distances_argmin. pairwise.py is not changed by this PR |
jnothman
left a comment
There was a problem hiding this comment.
LGTM, thanks!!
Please add an |Efficiency| entry to the change log at doc/whats_new/v0.23.rst. Like the other entries there, please reference this pull request with :pr: and credit yourself (and other contributors if applicable) with :user:
|
Thank you for the PR @alexshacked ! |
Fixes #16027
Attempting to reduce memory footprint of Birch.predict. Please see solution description at issue
#16027 (comment)
Benchmark script to be added soon