Skip to content

Precompute nn ranking for DR datasets - #841

Merged
scottgigante-immunai merged 6 commits into
openproblems-bio:mainfrom
scottgigante-immunai:dimensionaity_reduction/precompute_ranking
Feb 28, 2023
Merged

scottgigante-immunai merged 6 commits into
openproblems-bio:mainfrom
scottgigante-immunai:dimensionaity_reduction/precompute_ranking

Conversation

@scottgigante-immunai

Copy link
Copy Markdown
Collaborator

Adding a bigger dataset to the dimensionality reduction task accidentally cost us $1000, because we're computing pairwise distances on each dataset n_methods * n_nn_ranking_metrics times (which is a lot). This PR is a hack -- we precompute the NN ranking matrix, which is costly upfront, but it only happens once. Ideally we could define bespoke metric dependencies, but that sounds like a v2 feature.

cc @rcannood

@github-actions

Copy link
Copy Markdown
Contributor

Current build status

@lazappi

lazappi commented Feb 27, 2023

Copy link
Copy Markdown
Member

I agree this is a bit hacky. @michalk8 I think you added this originally during the jamboree, do you have any comments or maybe other suggestions for how this could be sped up?

@michalk8

michalk8 commented Feb 27, 2023 •

Copy link
Copy Markdown
Contributor

I agree this is a bit hacky. @michalk8 I think you added this originally during the jamboree, do you have any comments or maybe other suggestions for how this could be sped up?

The simplest would be to update the update data on figshare with the pre-computed ranking metrics, if possible.

@scottgigante-immunai

Copy link
Copy Markdown
Collaborator Author

I'd rather precompute it actively once per run than have it precomputed in the cloud -- better at least to have it be transparent about how it's calculated. In v2 we will be able to compose metrics of multiple components and pass data directly from the dataset to the metric (bypassing the method) which solves this problem in a much cleaner way.

@scottgigante-immunai

Copy link
Copy Markdown
Collaborator Author

In terms of how this could be properly sped up, it seems to me that most of these metrics don't actually need the full knn matrix computed. The big problem here is the memory cost of storing the full nxn dense matrix -- if we're only evaluating most of these metrics with _K = 30, without understanding the metrics completely I imagine we could probably also compute them with something like the 300 nearest neighbors for each cell rather than the 80000 nearest neighbors.

@scottgigante-immunai

Copy link
Copy Markdown
Collaborator Author

Tests passing at https://tower.nf/orgs/openproblems-bio/workspaces/openproblems-bio/watch/1jOQdpGEMso24E . I propose we merge it this way for now while @michalk8 proposes a more efficient computation so we don't have to subsample datasets for the entire task just for this metric. (One possibility -- just sample datasets before computing this metric??)

@codecov

codecov Bot commented Feb 28, 2023

Copy link
Copy Markdown

Codecov Report

Base: 95.60% // Head: 95.62% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (1047dc7) compared to base (86375dd).
Patch coverage: 96.49% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #841      +/-   ##
==========================================
+ Coverage   95.60%   95.62%   +0.01%     
==========================================
  Files         187      188       +1     
  Lines        4980     5000      +20     
  Branches      273      273              
==========================================
+ Hits         4761     4781      +20     
  Misses        141      141              
  Partials       78       78              
Flag Coverage Δ
unittests 95.62% <96.49%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...sks/dimensionality_reduction/datasets/zebrafish.py 85.71% <71.42%> (-14.29%) ⬇️
...nproblems/tasks/dimensionality_reduction/_utils.py 100.00% <100.00%> (ø)
openproblems/tasks/dimensionality_reduction/api.py 100.00% <100.00%> (ø)
..._reduction/datasets/mouse_blood_olsson_labelled.py 100.00% <100.00%> (ø)
...ity_reduction/datasets/mouse_hspc_nestorowa2016.py 100.00% <100.00%> (ø)
.../dimensionality_reduction/datasets/tenx_5k_pbmc.py 100.00% <100.00%> (ø)
...sks/dimensionality_reduction/metrics/nn_ranking.py 100.00% <100.00%> (+2.50%) ⬆️
openproblems/api/hash.py 95.77% <0.00%> (ø)
openproblems/tasks/denoising/datasets/pancreas.py 100.00% <0.00%> (ø)
...problems/tasks/label_projection/datasets/cengen.py 100.00% <0.00%> (ø)
... and 16 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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@scottgigante-immunai
scottgigante-immunai merged commit 0f3736b into openproblems-bio:main Feb 28, 2023
@scottgigante-immunai
scottgigante-immunai deleted the dimensionaity_reduction/precompute_ranking branch February 28, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants