[ENH] Distances: Optimize PearsonR/SpearmanR#2852
Merged
thocevar merged 3 commits intobiolab:masterfrom Feb 26, 2018
Merged
Conversation
0e915a6 to
1d5c34f
Compare
Codecov Report
@@ Coverage Diff @@
## master #2852 +/- ##
==========================================
+ Coverage 81.91% 81.92% +0.01%
==========================================
Files 326 326
Lines 55997 56031 +34
==========================================
+ Hits 45868 45903 +35
+ Misses 10129 10128 -1 |
* Use numpy.corrcoef in PearsonR * Optimize PearsonR/SpearmanR when computing pairwise distances on a single input table
... for the case where computing distances from two tables.
1d5c34f to
f837920
Compare
thocevar
reviewed
Feb 23, 2018
Contributor
thocevar
left a comment
There was a problem hiding this comment.
This looks ok. Do you have any measurements of how much we gain with this re-implementation of what we previously handed over to numpy and scipy?
| rho = rho[:2, :2].copy() | ||
| else: | ||
| # scalar if n1 == 1 | ||
| rho = stats.spearmanr(x1, axis=self.axis)[0] |
Contributor
There was a problem hiding this comment.
Are these two cases (if, else) necessary? At first glance stats.spearmanr seems to (efficiently) handle the case of a missing second attribute.
Contributor
Author
In [1]: import Orange, numpy
In [2]: d = Orange.data.Table(numpy.random.random(size=(200, 200)))
In [3]: %timeit Orange.distance.PearsonR(d)Before After In [1]: import Orange, numpy
In [2]: d = Orange.data.Table(numpy.random.random(size=(400, 200)))
In [3]: %timeit Orange.distance.SpearmanR(d[1:], d[:-1])Before After |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Description of changes
numpy.corrcoeffor PearsonRIncludes