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

Having trouble understanding normalized rank calculation #12

Open
rushabh31 opened this issue May 30, 2019 · 1 comment
Open

Having trouble understanding normalized rank calculation #12

rushabh31 opened this issue May 30, 2019 · 1 comment
Assignees

Comments

@rushabh31
Copy link

I read all the instruction and vignettes available for precrec package, but I am having trouble understanding, how normalized rank is being calculated for basic mode. It would be really helpful, if you can include small introduction or explanation about it in the documentation or here.

I am looking forward for your reply.

Great work!!

Thank you.

@takayasaito takayasaito self-assigned this Jun 10, 2019
@takayasaito
Copy link
Member

takayasaito commented Jun 10, 2019

Hi,

Normalized ranks are calculated as (ranks - 1)/(n - 1). Below is an example of R code to calculate normalized ranks in precrec.

> ranks <- c(3, 2, 1, 4)
> ranks
[1] 3 2 1 4
>
> n <- length(ranks)
> n
[1] 4
>
> (ranks - 1) / (n - 1)
[1] 0.6666667 0.3333333 0.0000000 1.0000000

Please notice the ranks in the example above are given higher ranks (as 1 is the best rank) for higher scores. It is different from the default R rank function.

> scores <- c(20, 75, 100, 1)
>
> # R's default rank function
> rank(scores)
[1] 2 3 4 1
>
> # precrec's rank function
> precrec::.rank_scores(scores)$ranks
[1] 3 2 1 4

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

No branches or pull requests

2 participants