Skip to content
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

🌌🧐 Macro evaluation #850

Merged
merged 117 commits into from
Mar 31, 2022
Merged

🌌🧐 Macro evaluation #850

merged 117 commits into from
Mar 31, 2022

Conversation

mberr
Copy link
Member

@mberr mberr commented Mar 28, 2022

Adds an evaluator for computing macro averaged rank-based metrics.

Also enables docstr-coverage and darglint for pykeen.evaluation and adds missing docstrings.

Dependencies

Copy link
Member

@cthoyt cthoyt left a comment

Choose a reason for hiding this comment

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

Needs a bit of high-level documentation. can you add some notes on this in understanding_evaluation.rst (e.g., what issues are caused by micro evaluation? how does macro evaluation work and how does it solve these issues?) Maybe copy-paste some of the content that didn't make it into the metrics manuscript

@mberr
Copy link
Member Author

mberr commented Mar 30, 2022

Needs a bit of high-level documentation. can you add some notes on this in understanding_evaluation.rst (e.g., what issues are caused by micro evaluation? how does macro evaluation work and how does it solve these issues?) Maybe copy-paste some of the content that didn't make it into the metrics manuscript

e1d41fb - feel free to adjust / rephrase

@mberr
Copy link
Member Author

mberr commented Mar 30, 2022

some parts of the metric description in the understanding evaluation part is incorrect, but also duplicated from the class doc itself, e.g., here, where the section about adjusted mean rank describes the adjusted MRR, and the expectation is incorrect.

Adjusted Mean Rank
******************
The expectation of an inverse-uniform distributed variable $\frac{1}{X} \sim \mathcal{U}(\frac{1}{a},\frac{1}{b})$
is $\mathbb{E}\left[\frac{1}{X}\right] = \frac{\ln b - \ln a}{b - a}$.
Given our uniformly distributed variable $r_i$ with parameters $a=1$ and $b=N_i$ and its corresponding
inverse-uniform distributed variable $r_i^{-1}$, we get:
.. math::
\mathbb{E}\left[r_i^{-1}\right]
= \frac{\ln 1 - \ln N_i}{N_i - 1}
= \frac{\ln N_i}{N_i - 1}
\doteq \frac{\ln n}{n - 1}
The expected value of the mean rank is then derived like:
.. math::
\mathbb{E}\left[\text{MRR}\right]
= \mathbb{E}\left[\frac{1}{n} \sum \limits_{i=1}^n r_i^{-1}\right]
= \frac{1}{n} \sum \limits_{i=1}^n \mathbb{E}\left[r_i^{-1}\right]
= \mathbb{E}\left[r_i^{-1}\right]
\doteq \frac{\ln n}{n - 1}
The adjusted mean rank (AMR) was introduced by [berrendorf2020]_. It is defined as the ratio
of the mean rank to the expected mean rank
.. math::
\text{MRR}^{*}(r_1,\ldots,r_n) = \frac{\text{MRR}(r_1,\ldots,r_n)}{\mathbb{E}\left[\text{MRR}\right] }
It lies on the open interval $(0, 2)$ where lower is better.

maybe it is better to directly link to the class reference?

@cthoyt
Copy link
Member

cthoyt commented Mar 31, 2022

@mberr good idea

src/pykeen/metrics/ranking.py Outdated Show resolved Hide resolved
Trigger CI
@mberr mberr merged commit 3dfdc30 into master Mar 31, 2022
@mberr mberr deleted the macro-evaluator branch March 31, 2022 14:20
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.

None yet

2 participants