Project-MONAI / Project-MONAI/MONAI

MMD's `y_mapping` is not convenient

Open
#8,095 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.7k
Forks
1.6k
Avg merge
5d 1h
Merged PRs (30d)
20

Description

Problem
I would like to use Maximum Mean Discrepancy metric with a kernel (e.g. gaussian kernel).

According to the reference paper, we have (eq. 3):

$${{MMD}}^2 = \frac{1}{m(m-1)} \sum_{i=1}^m \sum_{j\neq i}^m k(x_i, x_j) + \frac{1}{n(n-1)} \sum_{i=1}^n \sum_{j\neq i}^n k(y_i, y_j) - \frac{2}{mn} \sum_{i=1}^m \sum_{j=1}^n k(x_i, y_j)$$

with: $k(x,y) = <\phi(x),\phi(y)>$, $k$ being a kernel and $\phi$ a transformation.

It seems to me that in your implementation, you use the form with $\phi$ (which corresponds to y_mapping) rather than using the form with a kernel.

Suggested solution
As you mentioned in the docs, MMD is a "kernel-based method", so I would suggest to use the kernel form and replace the y_mapping argument with a kernel argument. It would be more consistent with common MMD implementations I found ([1], [2], [3] or [4]).

I would be happy to make the changes if you agree!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin at the Maximum Mean Discrepancy section in MONAI's metrics documentation and read the linked reference paper to understand the requested kernel form. Trace the implementation and any callers from that entry point; done means the API supports a kernel argument consistently with the documented MMD equation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.