Refactor SpearmanRankCorrelation to native PyTorch and remove SciPy dependency#3672
Refactor SpearmanRankCorrelation to native PyTorch and remove SciPy dependency#3672Prathamesh8989 wants to merge 6 commits intopytorch:masterfrom
Conversation
cfbf7be to
b9f1ba1
Compare
|
Hi @TahaZahid05, Thank you for the feedback! I've addressed the suggested changes and updated the implementation accordingly. Please let me know if there are any further adjustments needed from my side. |
b9f1ba1 to
206d5ac
Compare
|
Hi @TahaZahid05, Thanks for the suggestions! I've made the requested updates: Switched the rank calculation to use Please let me know if any further adjustments are needed. |
TahaZahid05
left a comment
There was a problem hiding this comment.
Just one last change, else everything else is good!
206d5ac to
a7ff5b3
Compare
|
@TahaZahid05, Please let me know if anything else needs adjustment. |
TahaZahid05
left a comment
There was a problem hiding this comment.
Thanks for the changes @Prathamesh8989. @vfdev-5 Looks good to me!
|
@Prathamesh8989, style checks are failing. Kindly fix them. |
|
yeah sure , fixing them. |
| # Tests | ||
| dill | ||
| filelock | ||
| packaging |
There was a problem hiding this comment.
Why do we add packaging here?
We already have it as ignite depedency here:
Line 20 in 6c3dfd9
There was a problem hiding this comment.
it gave me an error saying that the tests failed because of not having this , so tried to add this in requirements.txt
Removed 'packaging' from development requirements.
|
@Prathamesh8989 can you please verify your pre-commit installation? The code style checks are still failing. You may take a look at |
|
sure, i will get through it by tomorrow. |
983c626 to
07bd89f
Compare
|
@Prathamesh8989 it seems you have pushed unwanted changes when fixing the code style checks. All files in examples are also coming under file changed. Can you fix it? |
|
Hey @TahaZahid05, I ran pre-commit run --all-files, then staged, committed, and pushed the files. I believe that should be the correct workflow, but I might be missing something. Could you please guide me a bit on this? I haven’t yet figured out the proper way to verify it. Also, I’ll be having my practical and theory exams from 22nd to 30th April, so my response time might be a bit slow during that period. Kindly excuse the delay in advance. |
07bd89f to
983c626
Compare
|
@Prathamesh8989 Run the following set of commands: pip install -U pre-commit
pre-commit clean
pre-commit install
pre-commit run --all-files You'll see in your terminal: nb-clean.................................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
prettier.................................................................Passed
ruff check...............................................................Passed
ruff format..............................................................Failed
- hook id: ruff-format
- files were modified by this hook
1 file reformatted, 364 files left unchangedThen run |
|
@Prathamesh8989 the failure on MPS is real: https://github.com/pytorch/ignite/actions/runs/24736092143/job/72390524588?pr=3672 |
Fixes #3663
Description
This PR refactors the
SpearmanRankCorrelationmetric to use native PyTorch operations, effectively removing the hard dependency onscipyfor calculation.Key Changes:
_get_rankshelper function that calculates ranks using the "average" method for ties, ensuring parity withscipy.stats.spearmanr._spearman_rfunction with a pure PyTorch implementation using Pearson correlation on ranked tensors.Check list: