Skip to content

Example with ranking metrices #21138

Open

Description

@lorentzenchr

Describe the issue linked to the documentation

Some of the metrices in #2805 were implemented in #7739.

Suggest a potential alternative/fix

It would be nice to add (to) an example the usage of those ranking metrices with the addition of, e.g., kendall's tau and spearman's rho:

from scipy.stats import kendalltau, spearmanr
from sklearn.metrics import make_scorer

kenall_tau_score = make_scorer(kendalltau)
spearman_rho_score = make_scorer(kendalltau)

Activity

  1. added
    Easy
    on Sep 24, 2021
  2. glemaitre commented on Sep 24, 2021

    @glemaitre
    Member

    If I am not mistaken, I don't think that we have any example tackling the problem of recommendation. It would be nice to have a full example with a predictive model and the way to evaluate it?

  3. acse-srm3018 commented on Sep 27, 2021

    @acse-srm3018

    take

  4. adrinjalali commented on Oct 12, 2021

    @adrinjalali
    Member

    @acse-srm3018 are you still working on this? If you have a draft, feel free to open a draft PR, mark it WIP, and ask for feedback if you need any help.

  5. adrinjalali commented on Nov 8, 2021

    @adrinjalali
    Member

    You'd need to add a whole new example @sveneschlbeck , I wouldn't say it's the easiest issue to work on. You need to familiarize yourself with the structure of the examples under the examples/ folder, and add a new one in the appropriate place there.

  6. added
    Moderate
    and removed
    Easy
    on Nov 8, 2021
  7. 2 remaining items

  8. rth commented on Nov 8, 2021

    @rth
    Member

    I don't think that we have any example tackling the problem of recommendation. It would be nice to have a full example with a predictive model and the way to evaluate it?

    As far as I know ranking is not necessarily a primary evaluation metric in recommendation (see e.g. lightfm.evaluation): one cares more about how many relevant predictions are made in the first N, instead of whether it's first or third. Though I agree that it would still be be good to have a recommendation example, but maybe more for top_k_accuracy_score metric (which also doesn't have any examples apparently)?

    For DCG and NDCG what comes to mind is more a search or directly a ranking problem. There are a few ranking problems on OpenML maybe we could pick one (or find some other open dataset and put it there)? Though of course we can also illustrate them on a recommendation example.

    A side comment that https://www.openml.org/d/40916 looks interesting, but maybe too political. I do wonder how does the partial dependence plot of "Dystopia" wrt "Happines" looks like :)

  9. shivamchhuneja commented on Jun 4, 2025

    @shivamchhuneja
    Contributor

    Hi!

    Happy to pick this up.

    Just wanted to quickly confirm the direction before jumping in.

    It seems like there are actually two separate things we have here, and maybe it’s worth splitting this into 2 different issues:

    1. A recommendation example (something simple and educational, maybe video/movie based using cosine similarity) - this would flow more naturally into top_k_accuracy_score, which is usually what readers might have in mind and expect. Right now, k score doesn’t have any detailed example or walkthrough either, so we could build something that covers both.

    2. A pure ranking example - where it makes more sense to use kendall or spearman for evaluation. These metrics are usually used in search, not so much in recommenders so a separate item might make sense.

    My suggestion: I could start with the recommender + top_k_accuracy_score example first, since it would be what many users might expect when they come to this topic.

    After that, I can follow up with a ranking example using kendall and spearman.

    Let me know what direction makes more sense - happy to align on whatever would be most valuable for the readers!

    @StefanieSenger

  10. StefanieSenger commented on Jun 4, 2025

    @StefanieSenger
    Member

    Let's tag @lorentzenchr here, so he can evaluate your approach.

  11. shivamchhuneja commented on Jun 6, 2025

    @shivamchhuneja
    Contributor

    @StefanieSenger in the meantime I will get started with laying down a rough structure for the example, dataset etc. (stuff that would remain slightly constant irrsepective of the approach we take for this one)

  12. shivamchhuneja commented on Jun 9, 2025

    @shivamchhuneja
    Contributor

    Hey, just getting this thread going again

  13. adrinjalali commented on Jun 11, 2025

    @adrinjalali
    Member

    @shivamchhuneja feel free to fire up a pull request with your ideas and we can take the idea from there.

  14. shivamchhuneja commented on Jun 12, 2025

    @shivamchhuneja
    Contributor

    @adrinjalali thanks, sounds great, will setup the base ideas in a PR within the coming week :)

  15. Arraddhyyad commented on Jun 4, 2026

    @Arraddhyyad

    Hi! I'd like to work on this. My plan is to write an example that trains a model on a ranking-style dataset and then evaluates it using NDCG, Kendall's tau, and Spearman's rho, showing when you'd use each one. Let me know if this direction makes sense and I'll get started!

  16. shivamchhuneja commented on Jun 17, 2026

    @shivamchhuneja
    Contributor

    imo it sounds good @Arraddhyyad - just check once more if this was already picked up by someone or not once

  17. Arraddhyyad commented on Jun 23, 2026

    @Arraddhyyad

    Confirmed! no branches or PRs in the Development section. I'll get started :)

  18. added
    Hard
    and removed
    Moderate
    on Jul 5, 2026
  19. Arraddhyyad commented on Jul 9, 2026

    @Arraddhyyad

    Hi @StefanieSenger @lorentzenchr — opened #34427 for #21138 (NDCG / Kendall's tau / Spearman's rho ranking example). Checks are green and it's ready for review whenever you get a chance. Happy to adjust anything based on feedback — thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationHardmodule:metrics

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions