lucasmaystre / choix

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

Probability of win given pairwise probabilities #18

Closed nrcjea001 closed 3 years ago

nrcjea001 commented 3 years ago

Hi @lucasmaystre,

Thanks for taking the time to build this package. Its been of great help.

We are just struggling a bit around a particular problem and hoping you can assist. We are given a matrix pairwise probabilities and we need to compute the probability of win against all other queries in the matrix (i.e. probability of ranking first). How can we make use of your package for this problem.

Thanks.

lucasmaystre commented 3 years ago

Hi @nrcjea001 thanks for your interest!

I'm not sure I understand your problem completely. Could you give a toy example with the output you expect, to illustrate the problem & what you're trying to achieve?

You might also be interested in this stack exchange thread: https://datascience.stackexchange.com/questions/18828/from-pairwise-comparisons-to-ranking-python

Hope this helps.

nrcjea001 commented 3 years ago

Hi @lucasmaystre, thank you for your response.

In a nutshell, we need to compute the probability that a query will rank at the top of the list, given pairwise probabilities. For example, given A beats B with probability p1, B beats C with probability p2, and A beats C with probability p3, what is the probability that A wins overall (beating B and C). The formula would be p(A)=p1p2+p3(1-p2)

We need a general formula for this and when the number of queries gets large, I think the Bradley Terry model would apply.

I have seen the stack exchange and it looks like it solves our issue, however we need to return probabilities, not the log likelihood. Would return np.exp(nxt)/(1+np.exp(nxt)) be applicable?

Thanks

lucasmaystre commented 3 years ago

With regards to the solution in the stack exchange thread, you can get probabilities as follows:

params = mle(pmat)
probs = params / params.sum()

I think this is a good way to aggregate pairwise probabilities if you think that the probabilities are transitive (up to noise, you should expect to have p3 >= max(p1, p2) in your example). However I'm not sure these probabilities have the same interpretation as the formula you shared with me.

bdwilson24 commented 2 years ago

What do these probabilities refer to? Are they the probability of ranking first? I ran a probability matrix through the mle function from the Stack Exchange thread and grabbed these probabilities, but I'm struggling to interpret what they actually mean.

lucasmaystre commented 2 years ago

Hi @bdwilson24, yes you can think of them as probabilities of ranking first.

Another interpretation is as follows: probs[i] / (probs[i] + probs[j]) is the probability that i ranks better than j.