Code Monkey home page Code Monkey logo

ranking-metrics-torch's Introduction

ranking-metrics-torch

This is a small set of PyTorch-based CPU and GPU friendly implementations of common ranking metrics.

Included metrics:

  • Precision/Recall
  • Average Precision
  • Discounted Cumulative Gain
  • Normalized Discounted Cumulative Gain

Implementations are tested against scikit-learn with hypothesis property-based testing (where possible.)

ranking-metrics-torch's People

Contributors

karlhigley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ranking-metrics-torch's Issues

Wrong ndcg results when evaluating only one k

Hi @karlhigley, I just noted this oddity while playing with your implementation. Unfortunately, I didn't have time to further investigate the issue.

Observed behaviour:

import torch
from ranking_metrics_torch.cumulative_gain import ndcg_at

true = torch.tensor([[10, 0, 0, 1, 5]])
scores = torch.tensor([[0.1, 0.2, 0.3, 4, 70]])
ks = torch.tensor([3])
ndcg_at(ks, scores=scores, labels=true)

Returns
tensor([[1.]], dtype=torch.float64)

However adding another k to evaluate returns the correct ndcgs:

ks = torch.tensor([3, 5])
ndcg_at(ks, scores=scores, labels=true)

Returns:
tensor([[0.4124, 0.6957]], dtype=torch.float64)

ndcg score wrong and not matching sklearn.

Hi @karlhigley ,

while working on my own implementation of ndcg and checking it against sklearn's and yours, I noticed that your ndcg implementation produces different scores than sklearn. I added a simple unit test in this PR to demonstrate: #2

I am new to hypothesis and couldn't check why all your tests pass nevertheless. Maybe there is no bug and I am missing something?
The dcg scores are fine by the way (see first added test in PR). Looks to me like a problem with the normalizing gains but I don't understand the tie-aware implementation yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.