-
Notifications
You must be signed in to change notification settings - Fork 14
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
add rs.utils.weighted_pearsonr
and tests
#189
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
reciprocalspaceship/utils/stats.py
Outdated
|
||
Note | ||
---- | ||
x, y, and w may be arbitrarily batched. the correlation coefficient will be computed pairwise along the last axis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand the use of "batched" in this context. Perhaps an example with the corresponding array shapes would help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this better?
|
||
import reciprocalspaceship as rs | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your tests look good, but are there any simple cases that can be used to test the output for non uniform weight cases?
Right now the tests only compare to scipy (requires np.ones
weights) or tests execution. Is there a good test for correctness in the more general case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't know any. i'm happy to incorporate any examples you can find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep -- unsure. I'm ok with this as is given there isn't another reference implementation for the general case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can add a regression test. is that a good idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps -- do you mean by including a test against the current implementation? Also, is useful to test against scipy
using uniform weights that aren't np.ones
? Any uniform array should be equivalent, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes test against the current implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay i added a test against non-one weights and a test against a current result. i'll merge after ci.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good -- two small requests:
- I was a bit confused by your use of "batched" in the docstring. Please clarify with an example or by saying something about the shapes of the input and the expected output.
- I am wondering if there's an additional test of correctness that can be done for the non-uniform weights case. Right now, that only gets tested for execution, but not correctness.
for more information, see https://pre-commit.ci
Codecov ReportBase: 98.35% // Head: 98.36% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #189 +/- ##
==========================================
+ Coverage 98.35% 98.36% +0.01%
==========================================
Files 44 44
Lines 1764 1775 +11
==========================================
+ Hits 1735 1746 +11
Misses 29 29
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the docstring
…procalspaceship into weighted_pearsonr
for more information, see https://pre-commit.ci
I wrote a function to compute weighted Pearson correlation coefficients and added it to
utils/stats.py
.