Archive for the ‘Mathematics’ Category

Rank aggregation basics: Local Kemeny optimisation

Friday, June 18th, 2010

The technical content of this post is based heavily on Rank Aggregation Revisited” by Ravi Kuma, Moni Naorz, D. Sivakumarx and Cynthia Dwork. It’s purely expository in nature on top of that.

You’ve all seen Hammer Principle now, right? If not, go check it out.

The task it performs of aggregating all the individual opinions into a single overall ranking is harder than it looks. This is a post about some of the technical details involved.

The setup is as follows: We have a bunch of items, and a bunch of votes placing a subset of those items in order.

The naive idea one starts with is as follows: If the majority of people prefer A to B, rank A higher than B. This is an obvious thing to aim for. Unfortunately it’s impossible, even if everyone ranks every item. Considering the following set of votes:

1: A, B, C
2: B, C, A
3: C, A, B

Then 1 and 3 think A < B, 1 and 2 think B < C, and 2 and 3 think C < A. So if we tried to order by majority opinion we'd have A < B < C < A.

This is called Condorcet's paradox: Majority voting amongst > 2 items is impossible.

Nevertheless, we hope to be able to do at least reasonably well.

One natural approach is called Kemeny optimisation: We try to find a solution which minimizes the number of pairwise disagreements between the end rank and the individual voters. That is, for some set of items I, votes V and an aggregate ranking r, the score is

K(r) = #{ i, j in I, v in V, (r(i) < r(j)) != (v(i) < v(j)) }

If r is a minimum for this score we say it's Kemeny optimal. There needn't be a unique Kemeny optimal solution: In the above example, all three of the individual votes are Kemeny optimal rankings.

Kemeny optimal rankings have the following nice majority voting property:

Let r be Kemeny optimal. If U and V partition the set of items, and for every u in U and v in V the majority think u < v, then for every u in U and v in V r(u) < r(v).

Proof:

Suppose we had r(u) > r(v) for some u, v. By passing to a smaler u and a larger v we can ensure that there is no z with r(u) > r(z) > r(v). (we can take the smallest u such that r(u) > r(v) then the largest v such that r(u) > r(v)).

But then if we were to define the ranking r’ which is exactly r except that u and v were swapped, this would decrease K: Because there are no points between them, the only pairwise disagreements it changes are those on u and v, so K(r’) – K(r) = #{ t : t(u) < t(v) } - #{ t : t(u) > t(v)}. But we know the majority think u < v, so this change in score must be negative, so we have K(r') < K(r), contradicting minimality.

QED

We call the conclusion of this theorem the generalised Condorcet criterion (the condorcet criterion is that if there's a single element that beats all the others in a majority vote then it should be the winner). It's a nice property - it is in some sense an approximation of majority voting. In many cases satisfying it will uniquely determine a great deal about the resulting ranking - it's only when there's ambiguity (as in the Condorcet paradox example) that it fails to do so. This should give us confidence that the Kemeny optimal solution is the right approach.

So, we want to calculate a kemeny optimal solution.

There's just one problem: We've defined the problem in terms of a minimization over all rankings of n items, of which there are n!. This search space is, to borrow a technical term, freaking huge. This makes it a hard problem. In fact finding a Kemeny optimal solution for rankings on n items is NP hard, even with only four votes. I won't prove this here. Read the paper if you care.

So, no Kemeny optimal solutions for us. How sad.

What would work well as a substitute?

Well, examining our proof that Kemeny optimal solutions satisfy the generalised Condorcet condition, an interesting feature appears: We don't actually use anywhere that it is a global minimum. We only use the fact that swapping two adjacent pairs can’t decrease the score. This suggests the following relaxation of the condition:

A ranking r is locally Kemeny optimal if swapping two adjacent elements of the ranking does not decrease K.

By the above observation, locally Kemeny optimal solutions satisfy the generalized Condorcet condition.

This turns our problem from a global search to a local one: Basically we can start from any point in the search space and search locally by swapping adjacent pairs until we hit a minimum. This turns out to be quite easy to do. We basically run insertion sort: At step n we have the first n items in a locally Kemeny optimal order. Swap the n+1th item backwards until the majority think its predecessor is < it. This ensures all adjacent pairs are in the majority order, so swapping them would result in a greater than or equal K.

This is of course an O(n^2) algorithm. In fact, the problem of merely finding a locally Kemeny optimal solution can be done in O(n log(n)) (for much the same reason as you can sort better than insertion sort). You just take the directed graph of majority votes and find a Hamiltonian Path. The nice thing about the above version of the algorithm is that it gives you a lot of control over where you start your search.

The above algorithm however produces an ordering which is consistent with its starting point in the following sense:

If we start with a ranking r and then run the above algorithm on it to get a ranking r’, then if r’(u) < r'(v) we must have r(u) < r(v) or a majority vote that u < v.

This is easy to see: If r(u) > r(v) and the majority think that u > v then when moving u backwards we would have to stop at v at the latest.

In fact for any starting point there is only one kemeny optimal solution which is consistent for it in this way: We can see this inductively. If it’s true for the first n – 1 items, then where can we put the nth item? The only possible place is where the above algorithm puts it: If it were to put it after that place, it wouldn’t be Kemeny optimal. If it were to put it before it, it wouldn’t be consistent because it would be less than some item which it was greater than in the original ordering.

The unique locally Kemeny optimal solution is called the local Kemenization of the ranking.

So, this process gives us the core idea of the rank aggregation mechanism we’re using: We pick a starting point according to some heuristic (I’ll explain the heuristic we’re using in a later post), and from that starting point calculate its local Kemenisation. This gives us a ranking which is guaranteed to satisfy the generalised Condorcet condition, and thus likely to be a good ranking, but takes into account whatever our heuristic thought was important as well – this can matter a lot for cases where there is ambiguity in the ranking data.

Sequential compactness and the splitting number

Sunday, March 14th, 2010

In talking with people in #scala earlier I ended up looking through some of my old maths articles. In particular this one. I noticed that I mentioned “So far the only counterexampe I have depends on the value of the reaping number, tau. It’s fairly standard (I’ll write a post on it at some point) that {0, 1}^{tau} is not sequentially compact”.

The details of the above are wrong: Firstly, I meant the splitting number rather than the reaping number (a post I found elsewhere on the internet confirms I was confusing the two – I’m not even sure what the reaping number actually is). Secondly, “fairly standard” my ass. I couldn’t find anything on it, so had to recreate it from scratch. I mean, it’s not a new result and there have been papers on it, but it’s not by any means a commonly reproduced proof. I have no access to maths journals in order to check out the original papers, and hence there will be a deplorable lack of citations here. Sorry.

Still, four years later, here’s that post. I’ve written it up as a pdf rather than subjecting you to embedded LaTeX in the post.

Axioms, definitions and agreement

Sunday, June 28th, 2009

A while ago I posted A Problem of Language, a response to an article claiming that Scala was not a functional language. This isn’t an attempt to revive that argument (and please don’t respond to it with such attempts. I’m likely to ignore or delete comments on the question of whether Scala is a functional language). It’s a post which is barely about programming, except by example. Really it’s a post about the philosophy of arguments.

My point was basically that without a definition of “functional language” (which no one had provided) it was a meaningless assertion to make.

Unfortunately this point isn’t really true. I think I knew that at the time of writing but glossed over it to avoid muddying the waters, as it’s false in a way that doesn’t detract from the basic point of the article, but it’s been bugging me slightly so I thought I’d elaborate on the point and the basic ideas.

Let’s start with what’s hopefully an unambiguous statement:

Brainfuck is not a functional language

Hopefully no one wants to argue the point. :-)

Well, why is brainfuck not a functional language? It doesn’t have functions!

So, we’re making the following claim:

A functional language must have a notion of function

(in order to make this fully formal you’d probably have to assert some more properties functions have to satisfy. I can’t be bothered to do that).

Hopefully this claim is uncontroversial.

But what have we done here? We’ve, based on commonly agreed statements, proved that Brainfuck is not functional without having defined “functional programming language”. i.e. my claim that you need a definition in order to meaningfully claim that a language is not functional is false.

What you need in order to make this claim is a necessary condition for the language to be functional. Then on showing that condition does not hold you have demonstrated the dysfunctionality of the language.

But how do we arrive at necessary conditions without a definition? Well, we simply assert them to be true and hope that people agree. If they do agree, we’ve achieved a basis on which we can conduct an argument. If they don’t agree, we need to try harder.

A lot of moral arguments come down to this sort of thing. Without wanting to get into details, things like arguments over abortion or homosexuality frequently come down to arguments over a basic tenet: Do you consider a fetus to be of equal value to a human life, do you consider homosexuality to be inherently wrong, etc. (what I said about arguments RE Scala holds in spades for arguments on these subjects). It’s very rare for one side to convince the other of anything by reasoned argument, because in order to construct a reasoned argument you have to find a point of agreement from which to argue and that point of agreement just isn’t there.

Mathematically speaking, what we’re talking about is an Axiom. Wikipedia says:

In traditional logic, an axiom or postulate is a proposition that is not proved or demonstrated but considered to be either self-evident, or subject to necessary decision. Therefore, its truth is taken for granted, and serves as a starting point for deducing and inferring other (theory dependent) truths.

I consider this definition to be true, but perhaps a bit obfuscated. I’d like to propose the following definition. It’s overly informal, but I find it’s a better way to think about it:

An axiom is a point which we agree to consider true without further discussion as a basis for arriving at an agreement.

(This may give the hardcore formalists a bit of a fit. If so, I apologise. :-) It is intended to be formalist more in spirit than letter )

The most important part of this is that axioms are social tools. They don’t have any sort of deeper truth or meaning, they’re just there to form a basis for the discussion.

Old mathematics posts

Sunday, January 25th, 2009

I’ve imported my old maths blog, A Mathematician’s Scratchpad. It’s available under the category mathematics. Unfortunately I can’t get the LaTeX to compile. The old LaTeX-render plugin I used no longer works with the latest version of wordpress, and I’m experiencing a host of problems with the new one (not least among them “It makes my site shit-slow”), so I’ve disabled it. Hopefully it should be reasonably readable anyway.

Most likely none of this stuff is particularly interesting to anyone who reads this blog currently, but I’m enjoying the nostalgia trip. :-)

Silly Proofs 3

Monday, July 17th, 2006

Woo hoo. Blog is back. :-)

Here’s a new silly proof I spotted recently.

Theorem: Let [tex]f : \omega_1 \to \mathbb{R}[/tex] be continuous. Then [tex]f[/tex] is eventually constant.

Proof:

This proof assumes the that [tex]2^{\aleph_0} > \aleph_1[/tex]. The result doesn’t actually need this though, which is one of the main reasons this proof is silly.

So, [tex]f[/tex] is continuous. [tex]\omega_1[/tex] is countable compact, thus so is [tex]f(\omega_1)[/tex]. But [tex]\mathbb{R}[/tex] is a metric space, so countably compact subsets are compact. But every compact subspace of [tex]\mathbb{R}[/tex] has cardinality [tex]\aleph_0[/tex] or [tex]2^{\aleph_0}[/tex]. We know that [tex]2^{\aleph_0} > \aleph_1[/tex], so it can’t be [tex]2^{\aleph_0}[/tex]. Hence it has cardinality [tex]\aleph_0[/tex]. By the pigeon hole principle we must have [tex]f[/tex] being constant on some uncountable set. But for any [tex]t[/tex] the set [tex]\{ x : f(x) = t \}[/tex] is closed, with these being disjoint for distinct values of [tex]t[/tex]. You can’t have disjoint uncountable closed sets in [tex]\omega_1[/tex], so all but one of these sets must be countable. Thus take an upper bound for all the countable subsets, say [tex]y[/tex]. [tex]f[/tex] is constant on [tex] \[y, \omega_1) [/tex].