lucasmaystre / choix

Inference algorithms for models based on Luce's choice axiom
MIT License
158 stars 27 forks source link

partial ranking aggression #7

Closed quancore closed 6 years ago

quancore commented 6 years ago

I do not still understand which part/algorithm I should use for my problem. I have several partial ranking lists for n object (some of the rankings for some object may missing in a list) and I want to aggregate the list in a final ranking list. Which method I should use and how? How should I represent the item: ranking object for existing and nonexisting object?

lucasmaystre commented 6 years ago

Hi @quancore , I'm happy to try to help you. Can you provide a concrete example of data that you have? Suppose, e.g., you have 4 items, A, B, C, D, what observations do you make about them?

quancore commented 6 years ago

for example, I am trying to aggregate on player rankings collected on different resources. However, a list can be incomplete. there are four players -> a, b, c, d. The format is player:ranking. src1 ---> a:1, b:2, c:3, d:4 scr2 --> a:1,b:2,d:3 src2 --> b:1, c:2

I need a final aggregated list using resources given below. Thanks for your answers.

lucasmaystre commented 6 years ago

Ah, excellent. I refer to this type of data as partial rankings.

In choix, the n items are represented by consecutive integers 0 ... n-1. So, the first thing you'd need to do is to "relabel" your players with consecutive integers.

Next, you need to encode your observations (i.e., partial rankings) in Python using list. The convention choix uses is that

[3, 1, 0]

means

player 3 was ranked first, player 1 was ranked second, player 0 was ranked third.

Given a dataset of partial rankings, you can use the function ilsr_rankings to compute scores for each player. A complete example for your dataset would be as follows (supposing that player A is relabeled as player 0, B as player 1, etc...)

data = [
    [0, 1, 2, 3],  # src1 ---> a:1, b:2, c:3, d:4
    [0, 1, 3],     # scr2 --> a:1,b:2,d:3
    [1, 2],        # src2 --> b:1, c:2
]

est = choix.ilsr_rankings(n_items=4, data=data, alpha=1e-5)

if you want to get the ranking induced by the scores, you can use numpy.argsort:

np.argsort(est)[::-1]

which will give you array([0, 1, 2, 3]). This means that in the aggregate ranking, player 0 is ranked first, player 1 is ranked second, etc...

Hope this helps. Let me know otherwise!

quancore commented 6 years ago

Really thank you, pretty clear.