Chalking out an algorithm to rank the teams in Indian Premier League is not easy, considering the ever-changing format of the tournament. But when passion meets leisure, anything can happen over a PC!
I have always been a fan of the Indian Premier League, right from its inception in 2008. Though it has been in the news for all the wrong reasons recently, its popularity has not diminished one bit. It was during one of the matches involving my favourite team (Royal Challengers Bangalore) this year that me and some of my friends had an argument over the most successful teams in IPL’s history. They were adamant that RCB could not be considered among the top teams as it had not won a single season.
I had created a very primitive ranking system for IPL back in 2009 and had a fair idea of how a team needs to be ranked. Just counting the silverware will not give a fair picture of where each team stands. I could not convince my friends though and lost the big debate. What then does a programmer with a love of statistics, mathematics and cricket do? Create a custom ranking algorithm of course!
Before I started with the new algorithm, I tried to recall what my primitive algorithm looked like. I knew it took into account the number of seasons a team played, the number of teams participating in a season and the team rankings in a season. The sad part was that I forgot how these parameters were connected. I knew I had to start from scratch. So I laid down some ground rules for the algorithm:
1. The rankings would be based on a team’s performance in the IPL and will not take into account its performance in the Champions League T20.
2. The primary input to the algorithm would be a team’s ranking in a particular season.
3. For the sake of uniformity and continuity, if a team were to be renamed but remained from the same city (as was the case with DC/SRH) , they would be regarded as one team only.
4. Any team that has completed one full season in the IPL would be included in the rankings.
These criteria were comprehensive and, if used correctly in the algorithm, would make it independent of the number of seasons a team has played, the number of teams participating in different seasons and other flaws that might creep in due to the fact that there have been different number of teams playing in different seasons in IPL. Once these criteria were defined, the only job left was the creation of the algorithm itself.
The first step in creating an algorithm is to take a sample subset of the data you are going to process and create a prototype algorithm which you can then extrapolate to include the entire data. In this case, I took RCB’s record in six seasons. Their record is not spectacular for they have not won a single season. But it is not too bad either as they have been runners-up twice and semi-finalists once. They were above-average and ideal as a sample for the algorithm.
First, I collected their rankings in each season of the IPL: 7th/8, 2nd/8, 3rd/8, 2nd/10, 5th/9 and 5th/9. I collated these figures appropriately, summed up the ratios of each season and divided the figure by the number of seasons RCB have played. This gave me a progressive figure between 0 and 1 which accurately described the team’s performance over the years. Further modifying this algorithm so that it gave a number between 0 and 100, I arrived at the following formula:
X = 100 * [1 – (Σx)/S]
where, x = (R-1)/(N-1)
Here, X – Score; R – Rank of the team in a particular season; N – Number of teams participating in that season; S – Number of seasons played by that team.
The algorithm I created gave RCB a score of 60.05. I applied the algorithm to all the teams and here are the results:
1. CSK – 86.31
2. MI – 63.86
3. RCB – 60.05
4. RR – 47.88
5. DC/SRH – 44.24
6. KKR – 41.47
7. DD – 41.07
8. KXIP – 40.81
9. KTK – 22.22
10. PWI – 7.87
I tested the algorithm thoroughly for every scenario possible and it passed all the tests. Although there might be minor bugs in the algorithm, they would even out as the tournament progresses. It is safe to say that it should hold good for quite some time. The good thing is that this algorithm can be modified and used for every sports league, not just the IPL. All one needs to do is adapt it so that the scoring methodology suits the format of the league.
The rankings my algorithm gave prove my initial assertion that having more trophies in the cabinet does not make a team great. The fact that there are three teams in the rankings below RCB (RR, DC, KKR) that have won an IPL season proves that you ought to consider a team’s performance in every season to rank it. Or else, you might end up with a crappy ranking system that rates a team based only on top four appearances.
I think it is time I called my friends and restarted the debate!
Below are the rankings updated for the 2015 season:
1. CSK – 84.38
2. MI – 67.54
3. RCB – 55.75
4. KKR – 48.96
5. RR – 48.41
6. KXIP – 41.32
7. DC/SRH – 40.33
8. DD – 32.59
9. KTK – 22.22
10. PWI – 7.87