If LaLiga's title race wasn't tantalising enough already, Barcelona's shock defeat to Granada on Thursday really threw a spanner in the works.

It looks set to be the most gripping end to any of the top five European leagues this term, and almost certainly the least predictable finish to LaLiga since 2006-07.

Back then there were three teams in with a chance of taking home the title on the final day of the season – Real Madrid and Barcelona, of course, plus Juande Ramos' Sevilla.

As it was, Madrid and Barca won on the last day whereas Sevilla – who needed a win and for the other two to lose – lost at home to Villarreal.

Madrid finished top by virtue of a better head-to-head record over Barca, who were essentially denied the title by their local rivals Espanyol, slumping to a 2-2 draw with them on the penultimate day to hand Los Blancos the initiative.

For the first time since then, Sevilla are again in with a shout of upsetting established order, though on this occasion Atletico Madrid are in the mix as well.

In fact, with just three points separating first from fourth with five games left, it's the closest title race LaLiga has ever seen in a 20-team campaign (1987-1995, 1997-present).

Diego Simeone's side looked certainties for the title not too long ago: at the start of February, they were 11 points clear, but they've won only six of their 14 league games since, including a defeat to Sevilla in early April.

Yet, remarkably, it's still in Atletico's hands thanks to Barca's surprise loss at home to Granada on Thursday.

Barcelona lost to Granada, who massively out-performed their xG

What made that defeat even more incredible was the fact Granada had just 18 per cent of the ball and scored twice from an xG (expected goals) value of just 0.69. This means they netted more than two times as many as they should have, which speaks to how stunningly clinical they were.

Interestingly – or, infuriatingly, if you're a fan – it was Barcelona's second-highest share of the ball in a league game this season, behind only 82.1 per cent against Cadiz. They lost both games.

It's all shaping up for potentially decisive blows to be struck across May 8 and 9, when the top four all play each other – Barca host Atletico on the Saturday, with Sevilla going to Madrid the next day.

But what does our prediction model say about the most likely outcome in the title race?

How does the predictor work?

The data model estimates the probability of each match outcome – either a win, draw or loss – based on each team's attacking and defensive quality. Those ratings are allocated based on four years' worth of comprehensive historic data points and results, with more weighting given to recent matches to account for improvements or declines in form and performance trends.

The AI simulation takes into account the quality of the opposition that a team scores or concedes goals against and rewards them accordingly. All that data is used to simulate upcoming matches using goal predictions from the Poisson distribution – a detailed mathematical model – with the two teams' attacking and defending ratings used as inputs.

The outcome of the season is then simulated on 10,000 different occasions in order to generate the most accurate possible percentage chance of each team finishing in their ultimate league position.

Without further ado, let's have a good look at the results of the simulation with the predicted final league table…

Opta/Stats Perform AI predicts Atletico Madrid will win the title by virtue of a better head-to-head record against Barcelona

Atletico take the crown

There we have it… The AI predictor still sees Atletico as the likely champions, with a 38 per cent probability.

It essentially looks like it will come down to their showdown with Barca next Saturday. Atletico hold a slight advantage having beaten Barcelona 1-0 in Madrid earlier this season, and our predictor seemingly doesn't expect Ronald Koeman's men to overturn that at Camp Nou, as the model sees Atletico winning the title by virtue of their head-to-head record.

Nevertheless, Barcelona's outlook is almost identical to just a few weeks ago when the data suggested they had a 32.8 per cent chance, that now dropping ever so slightly to 32.6 – but you can't help but wonder what it would have been had they beaten Granada.

Madrid have drawn two of their previous three games 0-0, and so their chances have dropped from 34.4 per cent to a 26.6 per cent likelihood of winning the title.

Sevilla, perhaps unsurprisingly, remain the outsiders and our prediction model still only gives them a 2.8 per cent probability of winning their first league title since 1946.

However, that's 28 times more likely than just 18 days ago when the data gave them a 0.1 per cent chance of finishing top.

Everything seemingly hinges on next weekend…