<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by ML Soccer Betting on Medium]]></title>
        <description><![CDATA[Stories by ML Soccer Betting on Medium]]></description>
        <link>https://medium.com/@ML_Soccer_Betting?source=rss-8dd085a89796------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iOi9Y52z3c-zTDTmP04J_Q.jpeg</url>
            <title>Stories by ML Soccer Betting on Medium</title>
            <link>https://medium.com/@ML_Soccer_Betting?source=rss-8dd085a89796------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 16:11:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ML_Soccer_Betting/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Evaluating the GAP ratings in python]]></title>
            <link>https://medium.com/@ML_Soccer_Betting/evaluating-the-gap-ratings-in-python-9ab1b8a8d7c4?source=rss-8dd085a89796------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ab1b8a8d7c4</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[betting]]></category>
            <dc:creator><![CDATA[ML Soccer Betting]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 16:08:14 GMT</pubDate>
            <atom:updated>2024-01-15T16:08:14.632Z</atom:updated>
            <content:encoded><![CDATA[<p>In my previous <a href="https://medium.com/@ML_Soccer_Betting/implementing-the-gap-ratings-in-python-00bb46f39fa8?source=email-8dd085a89796-1705320680695-newsletter.subscribeToProfile-------------------------5ea25ec6_d149_4848_97c1_4fd17ae9f875--------9fe92793f786">article</a> I demonstrated a pythonic implementation of the GAP ratings system. In this article I will conduct an EDA on these ratings and evaluate their predictive power in the over/under 2.5 goals markets.</p><p>Firstly we use match goals as our input. This means that our ratings will give us expected goals scored. I removed the first three seasons of data. This is necessary as ample time is required to allow the ratings to mature. Here are the summary statistics for our ratings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/0*981RNh71T71mHv5J.png" /><figcaption><em>Summary statistics for the GAP ratings</em></figcaption></figure><p>We have 23,876 rows of data. The average rating is largest for ‘Home Attack’ and this feature also exhibits the greatest variance. With regards to our target variable, our dataset has a 48:52 split between under and over 2.5 goals respectively.</p><p>Lets look at how our ratings evolve over time for four teams:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*Rhd7MdaQQTVm_1qo.png" /><figcaption><em>Evolution of Home Ratings for Barcelona, Napoli, Bayern Munich and Manchester City</em></figcaption></figure><p>We can look at the distribution of our ratings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/0*qxHfbfteuzV_AxV2.png" /><figcaption><em>Distribution of GAP ratings and goals scored</em></figcaption></figure><p>We can see that the distribution of the ratings all have a positive skew, something they have in common with the distributions of goals scored.</p><p>Next we look at the distribution of our predictive feature. We are aiming to predict whether total goals will be over or under 2.5, so it makes sense to take the sum of each rating and use this as a predictive feature. This gives us the total expected goals scored for the two teams in each fixture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*gRfpBcKg6yO70vtW.png" /><figcaption><em>Distribution of the sum of GAP ratings</em></figcaption></figure><p>It appears that the feature is normally distributed. Finally before proceeding with fitting a model, let’s create a correlation heatmap:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/0*AtJxo5dZ7CuEVSC2.png" /><figcaption><em>Correlation heatmap: GAP ratings, o25 odds, o25 and total_goals</em></figcaption></figure><p>We can see from the visualisation above that the most strongly correlated feature we have is the attack_sum feature. This is the sum of the home and away attack ratings. The strongest correlation with the target variables o25 and total_goals is seen in o25_best — this feature represents the best available odds on over 2.5 goals. From this it appears unlikely that our feature will have greater predictive power than the bookmakers odds, but we may be able to combine the features in a model and produce predictions that do.</p><p>In order to evaluate the features, I will test a single variable logistic regression model against the bookmakers predictions. I take the bookies predictions as the implied probability of the best available odds. I’ll compare using ROC AUC, brier score loss and other metrics, and then run a betting simulation. This will be done using goals scored, shots on target, corners, and shots and corners, following the path set out in the original paper. Here are the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/0*58YdHCQ6eWa7du1b.png" /><figcaption><em>Results of a Logistic regression model-GAP feature + over 2.5 goals implied prob.</em></figcaption></figure><p>The GAP features alone are not enough to rival the predictive strength of the bookmakers implied probability. So we use both in the classifier. We are able to produce a bare improvement over the bookmakers predictions. The strongest performers are the corners ratings and the shots and corners ratings.</p><p>Finally we conduct a betting simulation over the length of our test set, which amounts to one full season (2022). The combination of GAP feature and bookies implied probability produced predictions that were near universally lower the predictions of the bookies. Consequently we had to choose an under 2.5 strategy which was unprofitable. So we selected the GAP features in a single variable logistic regression model and evaluate the predictions using a fractional (0.25) Kelly betting strategy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/0*nhiAgz14NVjlMROc.png" /><figcaption><em>Betting returns for Goals Scored as GAP input</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/0*o8jiJinMoDV0pGAp.png" /><figcaption><em>Betting returns for Shots on Target as GAP input</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/0*YYt2Do5zzj9oFmvf.png" /><figcaption><em>Betting returns for Corners as GAP input</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*JW54gyyAkV8gbuGF.png" /><figcaption><em>Betting returns for Shots and Corners as GAP input</em></figcaption></figure><p>Despite stronger performance in all of our metrics, the corners and shots on target plus corners models produce a much less profitable return, though both are still profitable. The goals and shots on target models not only produce significant returns (over 40%) but also exhibit smaller variance in returns over the simulation.</p><p>This does not mean we have a winning strategy! The fact that our GAP feature log-reg model underperformed the bookies, especially w.r.t the Brier score and the ROC-AUC score suggests that in the long term the results seen above would not hold. But considering the simplicity of the model, ie 1 single feature and a basic log-reg model that has not been optimised, this is a promising start and shows the potential of the GAP ratings for predicting total goals in soccer matches.</p><p>That’s it for now, follow for more! My next article will detail how to run a comprehensive betting simulation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ab1b8a8d7c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing the GAP ratings in python.]]></title>
            <link>https://medium.com/@ML_Soccer_Betting/implementing-the-gap-ratings-in-python-00bb46f39fa8?source=rss-8dd085a89796------2</link>
            <guid isPermaLink="false">https://medium.com/p/00bb46f39fa8</guid>
            <category><![CDATA[betting]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[ML Soccer Betting]]></dc:creator>
            <pubDate>Sat, 13 Jan 2024 16:27:44 GMT</pubDate>
            <atom:updated>2024-01-13T21:02:18.229Z</atom:updated>
            <content:encoded><![CDATA[<p>The Generalised Attacking Performance (GAP) rating system, introduced by Wheatcroft 2020, is a dynamic ratings system that aims to assess the attacking and defensive strengths of football teams. This article aims to explain and offer a pythonic implementation of the GAP ratings, and assess their effectiveness in predicting outcomes in the Over/Under 2.5 goals betting market.</p><p>Consider a football league with ’n’ teams. We use a specific match statistic (S_h for the home team, S_a for the away team) to gauge the attacking performance for each team in a fixture. This statistic could be goals, shots, shots on target, corners, or any combination of these, but the statistic should measure in some way the attacking performance of the team.</p><p>Each team is assigned four ratings: home attacking, home defensive, away attacking, and away defensive. To update these ratings, we apply the following mathematical rules:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*-ND3LXvtRQ-vGZNGlYuntw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*TK18DYV_PqpJQE8JRvJR3Q.png" /></figure><p>In these formulas; i and j refer to the ith and jth teams, H and A refer to home and away, and the subscripts h and a refer to home and away ratings. Parameters λ &gt; 0 and 0 &lt; φ_1, φ_2 &lt; 1 need to be determined by MLE. They control the influence of the latest match result and the learning rate of home vs away performance impact, respectively.</p><p>This idea of using a learning rate to update away rating based on home performance and splitting ratings into home and away are ideas borrowed from the pi ratings system. Wheatcroft goes a couple of steps further by splitting home and away ratings into attack and defense ratings and by allowing any attacking match statistic to be used, rather than just using goals. Another unique feature of the ratings is that they are constrained with a minimum value of zero.</p><p>When updating the rating, we estimate the expected number of attacking plays by taking the average of one teams attacking rating and their opponents defensive rating. We then assess their actual performance against this estimate. If a team’s attacking performance exceeds the average of its own attacking rating and the opponent’s defensive rating, we increase its attacking rating. Conversely, if the performance falls short of expectations, we decrease the rating. This adjustment is applied similarly across all four ratings.</p><p>Here is my implementation of these ratings in python:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/296cb321ad607fe948e65ef035963ed1/href">https://medium.com/media/296cb321ad607fe948e65ef035963ed1/href</a></iframe><p>Note that this implementation does not do anything to deal with newly promoted/relegated teams. In the paper linked in the first paragraph, the authors describe using an average of the bottom performing teams to initialise the ratings for new teams. In this code we initialise each new team at the baseline zero.</p><p>In the get_gap_ratings function we pass the params (lambda and phi_1,2) and the match statistic columns, i.e [‘Home_Score’, ‘Away_Score’] or [‘Home_SOT’, ‘Away_SOT’] etc.</p><p>The code starts by defining a function set_initial_ratings, which sets up the initial state for calculating GAP ratings. It creates four dictionaries to hold the home and away attacking and defensive ratings for each team in the dataset. These dictionaries are initialized with the baseline zero.</p><p>Then, we define two functions, get_home_ratings_update and get_away_ratings_update. These functions calculate how the ratings should be updated after a match. They take into account the current ratings, the match statistics (like goals, shots, etc.), and certain parameters (like gamma and theta) to adjust the ratings. The formula also ensures that ratings never drop below zero.</p><p>We then iterate over each row in the dataset, after converting the dataframe to a list of lists for speed. For each match, we take the home and away teams, retrieve their current GAP ratings and append these to the current row. Then, using the chosen match statistics and the update functions, the code updates the ratings for both the home and away teams based on their performance in that match. Parameters theta_h, theta_a, and gamma play the role of the parameters described earlier. Finally, the updated ratings are stored back into their respective dictionaries. By the end of the script, the dataset is expanded with new columns and converted back to a dataframe.</p><p>So, we have gone over the GAP ratings and their implementation in python. In the next article I will calculate these ratings for the top 5 European leagues over a ten year period and evaluate their predictive power.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00bb46f39fa8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tuning equation parameters with Optuna.]]></title>
            <link>https://medium.com/@ML_Soccer_Betting/tuning-equation-parameters-with-optuna-3e5b26217386?source=rss-8dd085a89796------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e5b26217386</guid>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[betting]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[optuna]]></category>
            <dc:creator><![CDATA[ML Soccer Betting]]></dc:creator>
            <pubDate>Wed, 09 Aug 2023 12:00:09 GMT</pubDate>
            <atom:updated>2023-08-09T12:01:10.049Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*-3wfSgAQbI4u9ZGVdUov0Q.jpeg" /><figcaption>Optuna library logo</figcaption></figure><p>Optuna is an optimisation library in python which was developed to automate hyperparameter optimisation for machine learning models. After defining an objective function and search space, Optuna will employ a user specified optimisation algorithm to intelligently search the parameter space to find the best configuration for your model. Despite its focus being model hyperparameter optimisation, it can be applied to a wider variety of optimisation problems. In this article, I will demonstrate how Optuna can be effectively employed to determine optimal parameters for a given equation.</p><p>Before getting into the code, here’s a brief overview of how Optuna works.</p><ol><li>We supply a dictionary of parameters, and indicate their range and datatype.</li><li>We define an objective function that will take as input these parameters as output some value which we ask Optuna to maximise or minimise.</li><li>We choose an optimisation strategy. Some of the strategies available include Tree-structured Parzen Estimators (TPE), Bayesian Optimization, and Random Search.</li><li>Optuna stores the choice of parameter and the result of the objective function, and continues sampling. The framework uses this information to choose the next set of parameters with the goal of obtaining a better result.</li><li>This continues until a user defined criterion, such as maximum number of iterations, is met.</li></ol><p>The library employs a pruning technique to expedite the process. If it determines that a parameter set is suboptimal based on intermediate results, it will terminate early and move on to the next choice.</p><p>I think we are ready to see what Optuna can do. Our task is to find the optimal integer value of the parameter k in the basic Elo ratings formulation for our soccer dataset.</p><p>We will be creating an Optimiser class for this task, with a structure that is as interchangeable as possible. Here is the basic structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*wnlXGbF6zofcwDKqtw8IzA.png" /></figure><p>Only the second and third part will be unique to our specific problem. We will make the rest of the code as general as possible.</p><p>In our problem we want to find the optimal value of k for the Elo ratings system. I have written an article about their implementation <a href="https://medium.com/@ML_Soccer_Betting/implementing-the-elo-ratings-for-soccer-teams-in-python-e3a067b024be">here</a>. So our second function in this class will calculate the Elo ratings for a given k for our soccer dataset, and return a test train split. Our goal is predict whether or not the home team wins.</p><p>We will use a LightGBM classifier model. The LightGBM model is a very fast one and is a highly accurate classifier. From the models predictions we will calculate the ROC AUC metric, and we will seek to maximise this value. I have chosen this metric as it is a good measure of the models ability to discriminate at varying thresholds, and this is what we want our model to be able to do very well. Other metrics we could have chosen include the Brier score loss, or a custom loss function that uses the bookies odds to evaluate the return on investment.</p><p>In the final function we will run the optimisation algorithm, print out our results, and return the set of best parameters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4618dad588df7f1d52ca4fe878c9d46/href">https://medium.com/media/d4618dad588df7f1d52ca4fe878c9d46/href</a></iframe><p>Above is the Optimiser class. In the function get_elo_rating we calculate our elo ratings for the entire dataset and return the subset containing our desired covariate Elo difference as well as the season and our target variable home win. It gives us a test train split based on the season.</p><p>This split is passed in the objective function to a LightGBM classifier which trains on the seasons preceding the 2022/2023 season and the is evaluated using the AUC metric on the 22/23 season. All you have to do, if you wish to use this code (which you are free to do!) is replace the processing function with your own and redefine the parameters in the objective function! I would recommend you stick with LightGBM as the model of choice for its speed!</p><p>Here are the printed results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*XC5_PNDnMG3sT4dKMrEiYw.png" /></figure><p>I will not evaluate these results. They could be compared with bookmakers odds, or compared against randomly chosen k, or k found by researchers, but the point of this article is demonstration, not comparative analysis of results.</p><p>The efficiency of this library might not be immediately apparent in a simple example like the one presented. A basic grid search over the same range of integers completes in nearly half the time. However, when searching for multiple float parameters, the speed and efficiency of Optuna truly shine, making it an advantageous tool for more complex optimization scenarios.</p><p>That’s it for this article! Follow for more. In the near future I will be writing more extensively on the inner workings of Optuna!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e5b26217386" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing the Pi ratings system in python.]]></title>
            <link>https://medium.com/@ML_Soccer_Betting/implementing-the-pi-ratings-in-python-d90da10fb070?source=rss-8dd085a89796------2</link>
            <guid isPermaLink="false">https://medium.com/p/d90da10fb070</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[football]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[ML Soccer Betting]]></dc:creator>
            <pubDate>Tue, 08 Aug 2023 16:34:25 GMT</pubDate>
            <atom:updated>2023-10-09T20:45:45.295Z</atom:updated>
            <content:encoded><![CDATA[<p>The pi-ratings were first described in this <a href="https://www.researchgate.net/publication/236944354_Determining_the_level_of_ability_of_football_teams_by_dynamic_ratings_based_on_the_relative_discrepancies_in_scores_between_adversaries">paper</a> to create informative covariates for soccer match prediction. In this article, I will demonstrate how to calculate these ratings and assess their predictive power for matches in the top European leagues.</p><p>The pi ratings build upon simpler rating systems like ELO in three distinct ways. First they introduce separate ratings for home and away performance. These are updated according to a defined rule and the rate at which they are updated depends on the second novel addition, two learning rates.</p><p>When team A plays against team B at home, we employ team A’s home rating and team B’s away rating. The ratings are then used to estimate how many goals the teams would score at home or away to an average opponent. We take this estimate and obtain the discrepancy between this and the observed goal difference. This error is then used to update the respective ratings of the home and away team.</p><p>The benefits to this approach are as follows:</p><ol><li>The ratings do not grow indefinitely, they are more stable than the Elo ratings.</li><li>There is distinction between home and away performance, and so home advantage is accounted for - unlike the ELO ratings. It is also the case that a teams away performances will impact on their home rating.</li><li>Margin of victory is accounted for, and there are diminishing rewards for higher goal differences.</li><li>A team can lose and still improve their rating if they outperformed expectations.</li></ol><p>These advantages, especially points 2 and 4, make the pi ratings a more realistic team-rating system compared to the ELO system.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85d2dc4b997fc3b1218321d5c460979a/href">https://medium.com/media/85d2dc4b997fc3b1218321d5c460979a/href</a></iframe><p>In this code, similar to the ELO implementation, I utilize a dictionary initialized with all team rating values set to zero. As we progress through the dataframe, we insert the current expected goal difference and pi ratings difference before updating and storing the ratings again.</p><p>Once we have calculated our ratings we can explore them further. We are going to be comparing these ratings with the Elo ratings system we discussed in a previous article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*J9Pk0VME-kk9goZ1v8gBCg.png" /></figure><p>The correlation heatmap indicates that the expected goal difference and the pi rating difference could serve as robust predictors for the binary target ‘home_win’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*7QyjTnoqXRViHZqiiOHrjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*pxJs9N0kaTvyGuS_iPUYSw.png" /></figure><p>These two charts present a visual comparison depicting the evolution of both Elo and pi ratings. It is clear that the pi ratings are much less volatile and that while there is very strong correlation between the home and away pi ratings, they are distinct and paints a more nuanced picture of a teams ability.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ddaea53af38636cff477c147c79e891/href">https://medium.com/media/7ddaea53af38636cff477c147c79e891/href</a></iframe><p>In the provided code snippet, we evaluate the predictive performance of our newly introduced ratings and compare them to both our Elo ratings and the bookies’ predictions.</p><p>The dataset is divided into training and test sets. Specifically, we utilize the entire 2022/2023 season as our test set, while employing all preceding seasons for training. Additionally, we perform scaling for normalization. When amalgamating all features, we employ Lasso regression to address the multicollinearity present in our data. Our results_df looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*T1yVhau4YlWp-sxHd0864g.png" /></figure><p>Integrating all features yields a higher accuracy than that of the bookies, demonstrating promise. However, the metrics of most importance, namely the Brier score loss and ROC AUC, do not exhibit comparable improvement. In both these metrics, the bookies’ predictions significantly outperform our model, indicating their greater proximity to the correct labels.</p><p>Something that was unexpected to me is that the expected goal difference derived in the pi ratings calculation emerges as the most effective predictor. Maybe using ratings and clever mathematics to derive accurate estimates of the goal difference is a viable path to a model that can outperform the bookies! Finally here is a chart illustrating the performance of each feature over the course of the football season:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*M8IpALOE99y0YHZWW6_1GQ.png" /><figcaption>Performance over the season. Bookies predictions in black.</figcaption></figure><p>That’s all I have for this article, feel free to use any of the code above. In the next article I will show you how to implement the ratings system described <a href="https://link.springer.com/article/10.1007/s10994-018-5747-8#Equ1">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d90da10fb070" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing the ELO ratings for soccer teams in python.]]></title>
            <link>https://medium.com/@ML_Soccer_Betting/implementing-the-elo-ratings-for-soccer-teams-in-python-e3a067b024be?source=rss-8dd085a89796------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3a067b024be</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[betting]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[football]]></category>
            <dc:creator><![CDATA[ML Soccer Betting]]></dc:creator>
            <pubDate>Tue, 08 Aug 2023 14:37:53 GMT</pubDate>
            <atom:updated>2023-08-08T16:11:36.876Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article I will present pythonic implementation of several variations of ELO ratings and examine their performance in a simple logistic regression model.</p><p>The basis for my code to implement the ELO ratings can be found here:<br><a href="https://medium.com/mlearning-ai/how-to-calculate-elo-score-for-international-teams-using-python-66c136f01048">https://medium.com/mlearning-ai/how-to-calculate-elo-score-for-international-teams-using-python-66c136f01048</a></p><p>I have made changes to the code to speed it up.</p><p>First let’s take a look at our data. Our soccer data covers the top leagues in the four Scandinavian countries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UgF7EMbDldbd6Pb9MuWNQQ.png" /></figure><p>We have the team names, the country and league, the kick off time and the scores. The odds data is an average of bookmakers odds. Before obtaining our ratings we check our data for NaN values, and any inconsistencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdUYrIp6mlc736oO2opfhA.png" /></figure><p>We have only 2 NaN values, and they are in the odds columns. We can fix this easily. Now, the implied probability of our bookies prices should lie in the range between 1.04 to 1.10. The excess over 100% is called the overround and it is there to ensure the bookmakers always have an advantage. A total implied probability below 1.0 would imply an error in our data. The implied probability is calculated by dividing 1 by the decimal odds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WtlRitEPtR8ucS5lcS3PlQ.png" /></figure><p>The average is 106.9% with a small standard deviation. All values lie above 100%, indicated above by the red dotted line. We see only one outlier in the data which occurs at around index 2200.</p><p>After fixing this outlier and the NaN values we can proceed with the calculation of ratings. Here is the code:</p><p><a href="https://gist.github.com/klynch999/378150158313fab7ec6896208b7e90e2">https://gist.github.com/klynch999/378150158313fab7ec6896208b7e90e2</a></p><p>The code follows that of the article linked at the beginning, with some changes. You will find a detailed explanation of the code and the ratings there. The changes I’ve made are:</p><ol><li>Introducing a timestamp variable to ensure our data is ordered chronologically.</li><li>Converting the dataframe to a list of lists to speed up computation.</li></ol><p>The parameter k = 22 was found following optimisation. In later articles I will demonstrate how to find the optimal values for these parameters.</p><p>The next piece of code implements the goals-based ELO ratings, as outlined in this <a href="https://www.sciencedirect.com/science/article/abs/pii/S0169207009001708">paper</a>.</p><p>The ELO-goals rating is a modification of the basic ELO that takes margin of victory into account. To prevent extreme score lines from having a significant impact on the outcome, we cap the number of home goals and away goals at 6 before performing the calculation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/032c94a2f816a1cacce9e1fff770d92c/href">https://medium.com/media/032c94a2f816a1cacce9e1fff770d92c/href</a></iframe><p>The code is mostly similar to the first implementation, with the adjustment</p><pre>k = k*(1+delta)**mu</pre><p>So now k is not a constant, but depends on delta, the goal difference. The magnitude of the change in ratings now depends on margin of victory in addition to match outcome.</p><p>Finally, I introduce my own variation on the ELO ratings. This is very similar to the goals-based system. We amend it by replacing goal difference with the difference in their implied probabilities. This will mean that consistent favourites, who win when they are expected to will be given additional reward and inconsistent favourites additional penalty.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbeca5ec2999853acf077fa8a3c90fda/href">https://medium.com/media/dbeca5ec2999853acf077fa8a3c90fda/href</a></iframe><p>Before comparing their performance in a predictive model, let’s examine our features more closely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*zzlsSi6oVR9D2rTPgU3W_w.png" /></figure><p>Surprisingly enough, the basic ELO ratings shows the strongest correlation with our targets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*Rf5z648ckiE4rvFrVJ1oGw.png" /></figure><p>This chart shows the 250 period moving average of the correlations. The most stable is the ELO Goals based rating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*SatIUhOyaxYy-BfyhZuohw.png" /></figure><p>This chart shows the evolution of the ELO ratings for the Norwegian team Molde. Molde are strong performers in the Norwegian league. What is noticeable is the stability of the Odds based rating. The relative volatility of the basic ELO ratings can be attributed to the optimal k used for that ratings system.</p><p>We now compare the predictive power of each of our features, here is the code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c41072aa1d70722c687a5ac13c7b1dba/href">https://medium.com/media/c41072aa1d70722c687a5ac13c7b1dba/href</a></iframe><p>I compare the features using accuracy, precision, recall, brier loss, and roc auc. The inclusion of “home_ip” allows us to see how our features measure up against the bookies predictions. Then we create a Lasso classifier that uses an ensemble of all features to see if this improves our results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*utgBY0hOgHHQTrBoKtvMrQ.png" /></figure><p>The ELO rankings are clearly inferior in their predictive power compared to the bookmakers predictions. The basic ELO rating difference is the best performing of our features. Combining all features together improves the performance but we cannot match the performance of the bookies with these features. Most notable is the superior performance in the brier score loss and roc auc. These metrics measure how far off our probabilities are from the correct label. We will have to find better ratings!</p><p>That is it for this article, hope you enjoyed. I will be looking further into new adaptations of the ELO ratings using the bookmakers odds, and I will be publishing implementations of the ratings systems found <a href="https://www.researchgate.net/publication/236944354_Determining_the_level_of_ability_of_football_teams_by_dynamic_ratings_based_on_the_relative_discrepancies_in_scores_between_adversaries">here</a> and <a href="https://link.springer.com/article/10.1007/s10994-018-5747-8#Equ1">here</a>. Follow for more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3a067b024be" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>