Skip to content

Improve metrics documentation #204

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

LeonStadelmann
Copy link
Collaborator

No description provided.

@@ -54,15 +94,46 @@ def pairwise_squeuclidean(x: ArrayLike, y: ArrayLike) -> ArrayLike:

@jax.jit
def compute_e_distance_fast(x: ArrayLike, y: ArrayLike) -> float:
"""Compute the energy distance as in Peidli et al."""
"""Compute the energy distance between x and y as in Peidli et al.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make proper reference with :cite:, you might have to add the reference first.

)


def compute_e_distance(x: ArrayLike, y: ArrayLike) -> float:
"""Compute the energy distance as in Peidli et al."""
"""Compute the energy distance between x and y as in Peidli et al.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add proper reference

return r2_score(np.mean(x, axis=0), np.mean(y, axis=0))


def compute_sinkhorn_div(x: ArrayLike, y: ArrayLike, epsilon: float = 1e-2) -> float:
"""Compute the Sinkhorn divergence between x and y."""
"""Compute the Sinkhorn divergence between x and y.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -21,12 +23,38 @@


def compute_r_squared(x: ArrayLike, y: ArrayLike) -> float:
"""Compute the R squared between true (x) and predicted (y)"""
"""Compute the R squared score between the true (x) and predicted (y) distributions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually R squared between the means of x and y, please say so

Returns
-------
A scalar denoting the average MMD over all gammas.
"""
if gammas is None:
gammas = [2, 1, 0.5, 0.1, 0.01, 0.005]
mmds = [maximum_mean_discrepancy(x, y, gamma=gamma) for gamma in gammas] # type: ignore[union-attr]
return np.nanmean(np.array(mmds))


def compute_metrics_fast(x: ArrayLike, y: ArrayLike) -> dict[str, float]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we expose it, but not add to the docs? to keep it for backward compatibility ,but it's a bit redundant.

Copy link
Collaborator

@MUCDK MUCDK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@LeonStadelmann LeonStadelmann requested a review from MUCDK April 13, 2025 11:50
Copy link

codecov bot commented Apr 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.13%. Comparing base (ff7759a) to head (1d3a1f4).
Report is 73 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #204      +/-   ##
==========================================
- Coverage   79.88%   77.13%   -2.76%     
==========================================
  Files          38       38              
  Lines        2491     2497       +6     
  Branches      313      313              
==========================================
- Hits         1990     1926      -64     
- Misses        362      444      +82     
+ Partials      139      127      -12     
Files with missing lines Coverage Δ
src/cellflow/metrics/_metrics.py 90.90% <100.00%> (+51.20%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@MUCDK MUCDK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor changes pls, other than that looks good

return r2_score(np.mean(x, axis=0), np.mean(y, axis=0))


def compute_sinkhorn_div(x: ArrayLike, y: ArrayLike, epsilon: float = 1e-2) -> float:
"""Compute the Sinkhorn divergence between x and y."""
"""Compute the Sinkhorn divergence between x and y as in Feydy et al. :cite:`feydy:19`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cite once, i.e. Compute the Sinkhorn divergence between x and y as in :cite:feydy:19`.
Similarly in other places, please.

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.

2 participants