<?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 Imbafactory on Medium]]></title>
        <description><![CDATA[Stories by Imbafactory on Medium]]></description>
        <link>https://medium.com/@imbafactory?source=rss-2c54f4ff1c62------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*G-7xWGoehA194RaC71w9Bg.jpeg</url>
            <title>Stories by Imbafactory on Medium</title>
            <link>https://medium.com/@imbafactory?source=rss-2c54f4ff1c62------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:49:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@imbafactory/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[How to predict the outcome of a video game?]]></title>
            <link>https://medium.com/@imbafactory/how-to-predict-the-outcome-of-a-video-game-62e40d08b4e9?source=rss-2c54f4ff1c62------2</link>
            <guid isPermaLink="false">https://medium.com/p/62e40d08b4e9</guid>
            <category><![CDATA[esport]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[betting]]></category>
            <dc:creator><![CDATA[Imbafactory]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 15:09:31 GMT</pubDate>
            <atom:updated>2020-07-11T17:26:19.176Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to predict the outcome of an esports match?</h3><h4><strong>Part 1: Posing the problem</strong></h4><p>It is Monday evening and you are finally getting home after a long day of exhausting work. The time is to relax and to watch a nice e-sport game. You open your laptop and look for your favorite caster. Unfortunately, after 5 minutes of enjoying the game, your team is in trouble. You know they have little chances to win this match. Still, you hope for the best and even take a risky bet. Was it the right move?</p><p>Sure, they should be some AI able to answer this question… Right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TyjEfTVJCH3NL_LMQJsI0g.jpeg" /></figure><h3>Artificial Intelligence</h3><p>But what is Artificial Intelligence (AI) in the first place? Well, there is basically no consensus for that question. Nevertheless, in this specific case, the community would agree that an AI is a system/box transforming some input data (the current match) to some outcome (which team is going to win for instance). In practice, there is no magic or no thinking behind this system, the AI is simply a program making complex computations and outputting a number. In the field, we usually call this program a “model”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/0*A_B0W5O4_aBCM9w9" /><figcaption><strong><em>Figure 1: </em></strong><em>An AI is simply a program that answers a question based on some data. It can be seen as a complicated function. There is no thinking or magic involved. In this example, the AI estimates the winning chance of team 1 based on the game data.</em></figcaption></figure><p>The real challenge here is to find the correct model. One could try to directly program it with rules (if team 1 performs action X, then win_ratio of team 1 increases by Y). Obviously, for a complex game, it is nearly impossible to code such a program. The solution is to specify a template of computations instead and then to <strong>automatically</strong> fine-tune it thanks to some data. Mathematically, this template is simply a function class. Imagine for example that our input data is a number <em>X</em>. We could select the “polynomial of order 2” function class. The output would then take the form:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*8H2aR3I6q-KLsj32-h3HAA.png" /></figure><p>Here a_0, a_1 and a_3 are the parameters of our function f(x). The challenge is to tune them in order for the function to return the desired output. Once these parameters are found, we then obtain a model and can perform prediction for some new data X. The real question is: how can we do the parameter tuning?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/0*ABodkE5pvHz197Yk" /><figcaption><strong><em>Figure 2: </em></strong><em>Two polynomial functions (orange and green) trying to fit the data (blue crosses). The orange function does approximate the data much better than the green one. The question is: how to find the orange curve?</em></figcaption></figure><h3>Machine Learning</h3><p>Recently, data has become some new kind of gold because thanks to it, computers can automatically figure out the parameters of a model. This process is usually called Machine Learning (ML) and requires 3 things:</p><ol><li>Data (in our case, previously played matches)</li><li>A class function (a template of computation)</li><li>A loss (a way to provide feedback to the current model)</li></ol><p>Imagine the data is a collection of inputs with matching outputs that are like a list of exercises. For supervised learning, the ML process works as follows. We start with a random model, which will obviously be pretty bad and let the model compute the prediction of the input data. It is similar to a student that would do an exercise. Then, the loss, which can be seen as a teacher, provides feedback to the current model in order for it to improve. These two steps are then repeated until the model becomes “good enough”. Intuitively, large datasets will lead, up to a point, to better models as they contain “more exercise”. We call these exercise samples.</p><p>To be more concrete, let us illustrate the ML process with the Dota 2 game. Dota 2 is an online multiplayer video game and its first part, Dota created a new genre, called Multiplayer Online Battle Arena (MOBA). It is played by two teams, called Radiant and Dire which consist of five players each. The main goal of the game is to destroy other team’s “Ancient”, located at the opposite corners of the map. Each of the players chooses one hero to play with from a pool of 119 heroes in the drafting stage of the game (sometimes called ’picks’). Each hero has a set of features that define his role in the team and playstyle. Among these features, there are his basic attribute (Strength, Agility, or Intelligence) and a unique set of 4 (or for some heroes even more) skills. Additionally to that, there are 6 items slot for each hero which can be fulfilled among the more than 150 items available in the game. Skills are learned by experience and items are purchased by gold and both obtain through the game.</p><h3>The data</h3><p>For supervised learning, the data is composed of inputs and outputs. The definition of what they precisely depend on the task/goal. In the case of predicting the outcome of a DOTA 2 match, the output is simply going to be a boolean describing which team won the game. The input can be decomposed into two parts:</p><p>a) some fix attributes:</p><ul><li>Who are the players?</li><li>Which heroes did they pick?</li><li>What are the statistics of the players on their previous game?</li></ul><p>b) some attributes varying in time (we call these time series):</p><ul><li>What are the levels, health status, objects, positions of each player?</li><li>How much tower damage has been done by each team?</li></ul><h4>Preparing the data</h4><p>All of the input data has to be converted into numbers, as it is the only thing that we can compute with. So categorical attributes such as heroes and objects have to be transformed. The usual trick is the 1-hot encoding as illustrated below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/0*BCVYHlhel5G0Pmzh" /><figcaption><strong><em>Figure 3: </em></strong><em>1-hot encoding. Here each piece of equipment is associated with a column in the 1-hot code vector. If a player has the piece of equipment, then a 1 is inserted in the correct position. This technique allows us to convert categorical data to numerical data.</em></figcaption></figure><p>Eventually for our match prediction example, preparing the data consists of building, for each match, a vector of fixed attributes a_k, a matrix of attributes varying in time B_k, and an output y_k. Here k is the match index going from 1 to k (the number of matches in the dataset). For convenience, we will use next formula as the general input:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*HbM55g2NUzI0dovlmKkALQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aziMJyMEwkN9w8iy" /><figcaption><strong>Figure 4:</strong> The match data goes first through an information extractor block that converts it into three outputs: some fixed attributes (features), some time-varying attributes (features), and the match outcome. Then, some preprocessing is done to build the data input x_k = (a_k, B_k). Eventually ((a_k, B_k), y_k) is our data sample. Here a_k, B_k and y_k are only numbers and can be fed directly into our model.</figcaption></figure><h3>The class function</h3><p>Once the data is ready, the next task is to select the architecture of the AI. Designing the right computation template for each problem is an art. We will present in the second part of this blog post some of the ideas we are using. For now, less simply assume that we have two types of functions. The first one makes a pre-match prediction and is denoted: f_pre(a)</p><p>Such a model takes as inputs only the fixed attribute of a match and is used if one wants to predict the winning chances of a team <strong>before</strong> the match begins. The second one is denoted: f_live(a, B)</p><p>and is able to take into account the live actions of the players <strong>during</strong> the match for improved prediction.</p><h3>The loss</h3><p>The goal of the loss is to provide mathematical feedback to the current model prediction. Typically, we use a function that represents the prediction error. This function always has the property that the smaller it is, the better the model should perform. For the outcome prediction, it could simply be the percentage of wrong predictions. Let us assume that the selected class of function f always returns a number between 0 and 1. A typical choice is then to decide that if the output is greater than 0.5 (f(x) &gt; 0.5), then the model predicts the team 1 as the winner and otherwise the team 2. While this choice is very intuitive, it is probably not the wisest decision since 0.49 and 0.51 are almost the same prediction (or model output) but lead to a very different loss value. Instead, a better idea is to characterize how far the model prediction is from 0 or 1. The simplest loss that performs this task is the Mean Squared Error (MSE). To compute it, we take some matches x_k for k = 1, . . . K and evaluate their outputs: f(x_k). The MSE is then simply:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*4YtUTdxDTxTNCJI0q-SXrQ.png" /></figure><p>Here y_k is the actual outcome of the match (1 if the team 1 wins and 0 otherwise). Obviously, if the team 1 wins the match, the best that the function f can do is to get as close to 1 as possible (and reciprocally toward 0 if the team 2 wins the match).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/0*1qewm5a_pl9W4fCL" /><figcaption><strong><em>Figure 5: </em></strong><em>3 different losses. Here we assume that the network should return 0. In blue, the accuracy loss provides a very simple feedback as it is identical for many values (0.2 and 0.4 for example). Both the mean square error (orange) and the cross-entropy loss (green) do not have this issue and increase with respect to the distance to the target value.</em></figcaption></figure><p>The important question here is: <strong>Could the actual output of the model represent the win percentage of team 1?</strong> We cannot know the future before it happens. So in practice, predicting winning odds is the best we can do. Therefore we will dedicate part 3 of this blog post to this question. Shortly the answer is: If things are done correctly, then yes, the model can actually provide “arguably unbiased” odds.</p><h3>Results</h3><p>Thanks to a well-chosen loss and a large dataset of matches (200&#39;000), we tuned the parameters of our model f (using <a href="https://medium.com/quantyca/gradient-descent-in-deep-learning-b1077b89af81">gradient descent</a>). The question at this point is: what is the performance of the obtained model? And most importantly, can we do better?</p><p>The first question can easily be answered with some practical evaluation. Unfortunately, we are actually cursed and we will never be able to answer if the model can still be improved or not. Since we cannot predict the future, the performance has to be bounded, but we do not know by how much. So we hit a performance threshold, we never know if we reached the limit of the problem or if our model is sub-optimal. The only thing we can do is try to find a better model.</p><p>Another important aspect to consider is: what type of match/data do we want to predict the outcome and in particular what kind of level do we target? For maximum performance, we need to fine-tune our model for the particular level we are interested in. In this case, we decided to predict professional matches and we evaluate our model on matches from top tier tournaments and leagues like <a href="https://www.dotabuff.com/esports/leagues/11629-esl-one-los-angeles-2020-powered-by-intel">ESL One</a>, <a href="https://www.dotabuff.com/esports/leagues/11657-starladder-imbatv-dota-2-minor">StarLadder ImbaTV</a>, <a href="https://www.dotabuff.com/esports/leagues/11490-weplay-bukovel-minor-2020">WePlay! Bukovel</a> and <a href="https://www.dotabuff.com/esports/leagues/11517-dreamleague-season-13">DreamLeague</a>.</p><p>Figure 6 below shows the performance of the model we trained. To estimate if we did a good job with our model, a baseline is needed. Conveniently, the game is also estimating the winning probabilities of each team which provides us with a reference. Figure 6 shows both the accuracy and the confidence for both the reference and our model. The accuracy is simply the percentage of correctly predicted matches. The confidence is an estimation of how sure the prediction is (0.51 is not confident while 0.99 is). As you can guess, if the model predicts correct (calibrated) odds, then its confidence should match its accuracy. On this small set of 983 professional matches, the model significantly outperforms game odds in terms of accuracy, especially at the beginning of the game (before minute 20). So it seems we did a good job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/0*73jllSMTvHE_Beca" /><figcaption><strong><em>Figure 6: </em></strong><em>Results of professional matches. The model is outperforming the game odds, especially at the beginning of the game (when the game is still very uncertain). Note that both the model and the game data are conservative in their predictions.</em></figcaption></figure><p>We also see that both the model and the game odds are under-confident. This might be explained by many factors including a bad model. Nevertheless, we believe that the problem is somewhere else. It can come from the fact that 983 matches are not really enough for an accurate evaluation. One sign that this might be problematic is the fact that the accuracy curves are not very smooth. Another possibility is that our model might be tuned for the wrong kind of data. As the number of professional matches is limited, we also included high-level matches to increase our dataset size. As a result, it is likely that our model is calibrated for high-level matches and not for a professional one. Indeed, we found that the same curves for 4096 high-level matches are much closer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/0*noXXjB_U-IKevCPE" /><figcaption><strong><em>Figure 7: </em></strong><em>Results of high-level matches. The model is outperforming the game data percentage but with a much smaller margin. Are these matches less predictable? Or is it the result of our fine-tuning toward professional matches?</em></figcaption></figure><h3>Conclusive thoughts</h3><p>Practically, the quality of the predictions is highly dependent on the input data. In other words, to get good predictions, we need reliable data and wisely selected features. For that reason, we at <a href="https://imbafactory.com/">Imbafactory</a> have developed a very robust and reliable API where you can get all the data for history matches as well from live matches.</p><p>Stay tuned for part 2, where we will explain the magic behind the model we use.</p><blockquote>Nathanaël Perraudin</blockquote><blockquote>Machine Learning researcher at the Swiss Data Science Center and member of the Imbafactory team</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62e40d08b4e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>