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

Plackett-Luce question #245

Open
kejadlen opened this issue May 27, 2022 · 4 comments
Open

Plackett-Luce question #245

kejadlen opened this issue May 27, 2022 · 4 comments
Labels
good first issue Good for newcomers

Comments

@kejadlen
Copy link
Contributor

Hello there, I wanted to use this algorithm in Ruby and started porting the code over, but I have a question about your implementation of Plackett-Luce.

const [omegaSum, deltaSum] = teamRatings
.filter(([_qMu, _qSigmaSq, _qTeam, qRank]) => qRank <= iRank)
.reduce(
([omega, delta], [_], q) => {
const quotient = iMuOverCe / sumQ[q]
return [
omega + (i === q ? 1 - quotient : -quotient) / a[q],
delta + (quotient * (1 - quotient)) / a[q],
]
},
[0, 0]
)

There's a reduce after a filter, so wouldn't the q index be incorrect when indexing into sum_q and c, or am I misunderstanding the code here?

@vivekjoshy
Copy link
Collaborator

I had the same issue porting to python, but I ended up using for loops instead. Maybe this will give you more insight into what is going on in the code.

https://github.com/OpenDebates/openskill.py/blob/ad8dc00f0dc15e00a39d3a84840fd0f85ac85bfb/openskill/models/plackett_luce.py#L20-L38

@kejadlen
Copy link
Contributor Author

Thanks - I'd actually been using your codebase as well for a reference for my Ruby port already!

Poked around a bit more, and I think it doesn't matter, since the teams are sorted by rank coming into the model already, so the filter is only removing teams from the back of the list and the indices are the same in the end.

          omega_sum, delta_sum = team_ratings
            .filter {|_,_,_,q_rank| q_rank <= rank }
            .map.with_index
            # .filter {|(_,_,_,q_rank),_| q_rank <= rank }
            .inject([0, 0]) {|(omega, delta), ((_,_,_,q_rank), q)|

@philihp
Copy link
Owner

philihp commented Sep 13, 2022

Hi!

You have a keen eye to spot this!

Apologies for missing this and thank you @daegontaven for responding so quickly. You may also be interested in the source code in the zip file at https://www.csie.ntu.edu.tw/~cjlin/papers/online_ranking/ which I ran to generate a lot of my test cases, and then I wrote a lot of my code in a functional style, but verified that my outputs were the same.

It's not an issue with sumQ because both of them have the filter where q <= i but I guess I reversed the order on the util vs the model! Since you found it, would you like to submit a PR to flip one of them and make it ever so easier to read?

I think you've found a problem with a though. Usually this just returns an array of 1 for every team, because there's always 1 team at every rank. I think we might have issues with something like rank: [1,2,2,3,3,3]; a bit contrived, but that would explain why it has never before been an issue. I'm gonna reopen this so I don't forget to take a look sometime.

@philihp philihp reopened this Sep 13, 2022
@philihp
Copy link
Owner

philihp commented Oct 10, 2022

Opening this issue up to anyone on hacktoberfest — good start would be to create a test case with ranks [1,2,2,3,3,3] and identify an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants