<?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 Jonduke on Medium]]></title>
        <description><![CDATA[Stories by Jonduke on Medium]]></description>
        <link>https://medium.com/@jonduke90?source=rss-6e3e3636f32f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LbYMEL-sypSDparI</url>
            <title>Stories by Jonduke on Medium</title>
            <link>https://medium.com/@jonduke90?source=rss-6e3e3636f32f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:07:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jonduke90/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[Attempting to predict League of Legends match outcomes]]></title>
            <link>https://medium.com/@jonduke90/attempting-to-predict-league-of-legends-match-outcomes-9b92814a0215?source=rss-6e3e3636f32f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b92814a0215</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[league-of-legends]]></category>
            <category><![CDATA[predictive-modeling]]></category>
            <dc:creator><![CDATA[Jonduke]]></dc:creator>
            <pubDate>Fri, 06 Mar 2020 17:30:07 GMT</pubDate>
            <atom:updated>2020-03-06T17:45:34.037Z</atom:updated>
            <content:encoded><![CDATA[<p>Now that I’m learning how to do predictive modeling, I start to look at many things and ask “can this be predicted or not”? So when I found a dataset of about 50 thousand League of Legends matches, I decided to give it a try. I’ll save you the long read and say it here: I was not successful. I was still able to get a few insights though, so read on to see how it was all done and what I did learn.</p><h4>The game</h4><p>First, let me explain a bit about the game for those who are not familiar. <a href="https://en.wikipedia.org/wiki/League_of_Legends">League of Legends</a> (a.k.a. League or LoL) is a team-based strategy action game where two teams of 5 battle against each other. The game itself has been around since 2009, and is still popular to this day. In fact, it is one of the top e-sports games out there, and has international tournaments with millions of dollars in prize money. <a href="https://www.theverge.com/2013/11/19/5123724/league-of-legends-world-championship-32-million-viewers">These finales can even get more viewers than the Super Bowl.</a></p><p>Each of the 10 players picks one of over a hundred unique champions, all with their own abilities and stats. The main goal is to fight your way into the other team’s base and destroy their nexus (the big building in the back of each side).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*buiIdjw55RKk113J7-KHug.jpeg" /></figure><p>There are many different strategies that teams can use to win, but since there are so many champions to choose from I wanted to focus on that with my predictions.</p><h4>The data</h4><p>The original dataset can be found on Kaggle: <a href="https://www.kaggle.com/datasnaek/league-of-legends">https://www.kaggle.com/datasnaek/league-of-legends</a></p><p>While it would be possible to get this same data from the official API, having a dump of 50 thousand matches is really convenient. It does give me an important limitation though: this data is a couple years old. Leauge is constantly tweaked and rebalanced to keep things fair, so any predictions here may not exactly work on today’s game. The biggest difference is the number of champions: this data includes 138 different champions, but today there are 148 of them.</p><p>Let’s look at the data itself:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b4021a7228308f6d0bcd67c6e18a45f/href">https://medium.com/media/2b4021a7228308f6d0bcd67c6e18a45f/href</a></iframe><p>I have already performed a train/validate/test split here, so the training set seen is about 36k of the total 51k rows.</p><p>I am considering this data in two categories: pre-match and post-match. Pre-match data is what we know before the match starts, mainly which champions and spells are picked. Post-match data is statistics we get during or after the match, such as the game duration and number of kills. For my predictions, I am only using pre-match data since I want to predict the winner ahead of time.</p><p>For fun I did try some other columns and found that even simple default models could predict the winner more than 90% of the time when given post-match data. Even just the columns ‘t1_towerKills’ and ‘t2_towerKills’ resulted in 95% accuracy. However, this simply tells us that when one team wins, they generally destroy more towers than the other team. One does not necessarily cause the other. Insights like this are interesting but were not the focus of this project so I moved on to just the data I could use.</p><h4>Finding statistics</h4><p>While I could potentially run a model by putting in only the champions each player picked, I wanted to get some better statistics that I could also use as features. Statistics like pick rates and win rates are commonly tracked by others who analyze League data, but I calculated my own in this case using the matches in my train and validation datasets.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b00833169e237ad0c713c1197c1c693/href">https://medium.com/media/1b00833169e237ad0c713c1197c1c693/href</a></iframe><p>The last column is the only exception, while there are places I could pull the info automatically, I just manually looked that up for this project. It represents the most common roles each champion is used in.</p><p>The pick, ban, and win count and rate columns simply show how often each champion was picked by a player, banned by a player, or won a match they were in. And the baron and dragon columns give the average number of baron and dragon kills that teams got when this champion was on that team.</p><p>Since there are only 9 spells in the game, I did not spend much time on them. I did chart how often they were all used though. Remember that each of the 10 players gets to pick 2 spells.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8BZZt8RcrSCaUtRATUMQnw.png" /></figure><p>And of course who doesn’t love some top 10 lists. Here’s the top champions for pick, ban, and win rates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*omt3sthUzOOIKOJMbtRSbw.png" /></figure><p>Interestingly, those rates aren’t strongly correlated with each other. By graphing them as seen below, we can see that the pick and ban rates are only loosely related and have a lot of variance, while win rates are fairly consistent across the whole roster. It was also interesting to find the outlier that the least picked champion also had the highest win rate (in these matches, at least).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IjsenA6MhMmHcg4NdQIm4w.png" /></figure><h4>Feature engineering</h4><p>Now that I had those statistics, I could apply them to my pre-game data and generate some more information about each match. For each of the different statistics I had, I calculated the average of the 5 champions on each team to get an overall statistic for that team. I also calculated the difference between the teams’ statistics so I could directly compare them. Lastly, using the roles that I looked up I added a feature to tell if each team had one of each of the 5 roles (the ‘meta’ columns). Note that this is only an approximation since many champions are viable in more than one role and I only recorded their most popular one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3441e5387d0d744b834668cd3fe2fc26/href">https://medium.com/media/3441e5387d0d744b834668cd3fe2fc26/href</a></iframe><p>Once I had done that, I had some numerical data I could explore. I split my training data by which team won, and made more visualizations. This was where I got my first clue that this would be difficult to predict.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UwUwOX1EPjx-_xztFBUHRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TX1Kd5RRosyZz1XyogC2BA.png" /></figure><p>Even after going so far to calculate individual champion statistics and apply them to the teams in each of the matches, every feature I had was distributed the same regardless of which team won. This meant that none of them would end up being very strong predictors. But I came this far already, so it was time to actually try predicting things.</p><h4>Models and Predictions</h4><p>The first place to start with any predictive modeling project is to find a baseline. In my training data, team 1 won 51% of the matches, so that became my majority baseline.</p><p>Since I am still new to predictive modeling and wanted to learn more, I decided to try many different things to get a feel for how they all worked. In the end I picked 4 sets of features, 6 models, and 8 encoding methods, then ran all of them with (mostly) default hyperparameters and recorded the results.</p><p>The feature sets I chose were as follows:<br>- All available features (all pre-game data and all engineered features)<br>- Handpicked features (the 10 champions picked on each side, and 8 of the engineered features)<br>- Champions picked (just the 10 champions picked)<br>- Engineered features (just the 20 engineered features I ended up with)</p><p>The models and encoders are all from Scikit Learn, more info can be found here<br>- <a href="https://scikit-learn.org/stable/supervised_learning.html">https://scikit-learn.org/stable/supervised_learning.html</a><br>- <a href="https://contrib.scikit-learn.org/categorical-encoding/">https://contrib.scikit-learn.org/categorical-encoding/</a></p><p>And while I could print out tables of all the results, it’s easier to show it all in this handy graph:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplot.ly%2F%7EjDuke9%2F1.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fplot.ly%2F%7EjDuke9%2F1%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plot" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb39fc4d6494b3b79e2e77ce5399df43/href">https://medium.com/media/eb39fc4d6494b3b79e2e77ce5399df43/href</a></iframe><p>It was interesting to see Logistic Regression perform so well here. With the abundance of categorical data, I expected tree-based models to perform better. Categorical Naive-Bayes was also an interesting find. Since it could not take negative numbers as input (I could not find that in documentation, but the errors were very specific), the only data I passed to that one was the champions picked.</p><p>As you can see by the actual accuracy numbers though, none of the models are very good at predicting the winner. Though technically I did beat the majority baseline with each of them, depending on the encoder and features used.</p><p>I followed this up by selecting a few of the top models and used sklearn’s GridSearchCV for both hyperparameter optimization and cross-validation. The models I chose did end up with higher scores than the default settings shown in that graph, but not by much. I used the handpicked feature set on all except the last one.</p><ol><li>Logistic Regression with the LeaveOneOutEncoder<br> — This was my best result using default hyperparameters, and still my best after optimization.<br> — Cross-validation accuracy: 53.70%<br> — Final test accuracy: 53.53%</li><li>Gaussian Naive-Bayes with the MEstimateEncoder<br> — This one was my second strongest model both in the default search and after optimization.<br> — Cross-validation accuracy: 53.43%<br> — Final test accuracy: 53.94%</li><li>Random Forest with the JamesSteinEncoder<br> — While it wasn’t the strongest in my default search, I wanted to see how it performed after optimization. It improved, but is still behind the other models.<br> — Cross-validation accuracy: 53.22%</li><li>Categorical Naive-Bayes with the OrdinalEncoder<br> — The graph doesn’t show it, but all encoders got the same 49% score except for Ordinal. So even though it doesn’t make as much sense for unordered categorical data such as champion names, I used it here.<br> — This model only used the 10 champions picked.<br> — Cross-validation accuracy: 53.22%</li></ol><p>Now that I had some models, I could get a few more visualizations as well. I started with simple confusion matrices. They do at least show that we’re not simply picking one team all the time, and that the models are attempting to guess.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-m0M4u41yCUV6CeVB7o-g.png" /></figure><p>To look at individual features, I pulled the feature coefficients for the logistic regression model, and calculated permutation importances for the random forest model. The both show that most features have low importance values, though for what it’s worth the baron_delta feature was my strongest predictor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*_NGuNRDy951224aIBQBRPQ.png" /></figure><h4>Conclusions</h4><p>As you can see, even with all the extra statistical analysis I threw in I still could not confidently predict the outcome. No matter which champions each team picked, they still had even odds of winning.</p><p>In a way, this is a testament to how well-designed this game is. Balancing unique characters so that they are all viable is no easy task, and this game manages to do it with over 100 of them.</p><p>In the end, it is the skill and teamwork of the players themselves that decide a match. And maybe a bit of luck.</p><p>— <br>You can view the source notebook where I ran these models here: <a href="https://github.com/jonDuke/DS-Unit-2-Build-Week/blob/master/Unit_2_LoL_Project.ipynb">https://github.com/jonDuke/DS-Unit-2-Build-Week/blob/master/Unit_2_LoL_Project.ipynb</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b92814a0215" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing Steam Reviews and Users Data]]></title>
            <link>https://medium.com/@jonduke90/analyzing-steam-reviews-and-users-data-7a4ff3c5ce1a?source=rss-6e3e3636f32f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a4ff3c5ce1a</guid>
            <category><![CDATA[videogames]]></category>
            <category><![CDATA[steam]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jonduke]]></dc:creator>
            <pubDate>Fri, 07 Feb 2020 19:25:07 GMT</pubDate>
            <atom:updated>2020-02-07T19:25:07.290Z</atom:updated>
            <content:encoded><![CDATA[<p>I don’t know about you, but most of my recreational time ends up going to video games. So when I started learning data science and finding what data is out there that I could check out, of course I jumped onto the chance to analyze video game data! I found two datasets on Kaggle, one with Steam review data and another with Steam user data. In case you’re unfamiliar, Steam is the largest platform for PC gaming, with thousands of games and millions of users. Analyzing each dataset is interesting enough, but I also wanted to see what insights I could pull from the two combined. So let’s dive in!</p><h3>The Reviews Data</h3><p>Source: <a href="https://www.kaggle.com/luthfim/steam-reviews-dataset">https://www.kaggle.com/luthfim/steam-reviews-dataset</a></p><p>This data has a whopping 434,891 reviews in it! Steam reviews either recommend a game or not, so there’s no 5 or 10 star ratings here. They do have the review text in this data, as well as counts of how many hours the reviewer has played and how many other users said they found the review funny or helpful.</p><p>While the review text is interesting to us as people, it is meaningless to most programs and I am not at the point of trying to build a program that can understand it yet. Maybe that can be a project for another time, but here I ignore the review text. I do however keep in mind the length of the review, in number of characters.</p><p>This dataset ended up having reviews on 48 different games. However on closer inspection I found 23 of the games only had either 3 or 10 reviews. That’s not a great sample size, so I will keep that in mind later. The other 25 games all had at least 150 reviews, up to over 145,000 reviews for the most common game.</p><h3>Review Playtime</h3><p>A reasonable assumption might be that players will play games they like more than ones they don’t like. So does this data support that?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/0*I83L5TIvpseYDkqQ" /></figure><p>Just looking at the average hours played in each game vs how often the reviewers recommended it, the correlation is actually pretty low. Specifically, there is only a correlation coefficient of -.069 when including all games, or -.353 when considering the games with more than 10 reviews. (Remember, sample size matters!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*QqZ04pTH22wTkLeb" /></figure><p>If you look at the playtime of all reviews like this, it does appear there is a cutoff where players who did not recommend a game stopped playing altogether. However, notice that cutoff is around 12,500 hours! There also isn’t very many reviews with more hours than that.</p><p>Looking at the specific numbers, the median playtime on these reviews is 190 hours, and the average is 364 hours. Let’s take that median and say that’s “a lot” of time (and to people who don’t play a lot of games, yeah that is a lot).</p><ul><li>217,720 reviewers have played over 190 hours, and they recommend the game 73.23 % of the time</li><li>217,171 reviewers have played under 190 hours, and they recommend the game 66.38 % of the time</li></ul><p>For the record, those percentages are almost the same if you make the cutoff 364 instead. So while there is a difference between how long people will play games that they like or not, it is surprisingly small. This brings up an interesting point though, of just how many hours players have put into these games. So here’s a visualization of the hours played in each of the games we have more than 10 reviews for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/0*h01ZMYG2dKlE-grr" /></figure><p>And one last note, it turns out there were 6,258 reviews in this data that had 0 hours played. Not a lot compared to the 434 thousand total, but it is interesting.</p><h3>Review Length</h3><p>While I am not at the point of getting meaning from text data, I did wonder if there were any relationships to just how long the review is. In other words, are people more likely to write longer positive or negative reviews?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*UxNvNHYyVtMUAaCB" /></figure><p>Turns out, there is a difference! The positive reviews have an average length of 184 characters, while negative reviews have an average of 295. So perhaps people get more wordy when they’re unhappy? There is a common concept that people are far more likely to leave a review on a negative experience than on a positive one, so perhaps this is an extension of that.</p><p>Additionally, we also had data on if reviews were found funny or helpful by other users. Does that relate to the review length?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*mGpN4UNPQ0c3Z8ri" /></figure><p>Looks like there is not a relation there. Specifically, we only had correlations of .034 to funny votes, and .063 to helpful votes. So it turns out that the length of a comment really doesn’t tell us if people might find it funny or helpful.</p><h3>The Users Data</h3><p>Source: <a href="https://www.kaggle.com/tamber/steam-video-games">https://www.kaggle.com/tamber/steam-video-games</a></p><p>This data is a little simpler. Each row includes an anonymized user id, the game owned, and how many hours they have played in that game. This data is particularly interesting because Steam changed their policies a couple years ago and closed public access to individual user data like this.</p><p>I ended up with 129,535 instances of a user owning some game, 12,393 different users, and 5155 different games. So this data is a bit more general than the 48 games we had reviews for. On average each user owned 10.45 games, ranging from just 1 game owned to 1075.</p><h3>Bought but not played</h3><p>One interesting thing here is the number of users who own a game but never play it. By simply looking for how many rows have 0 hours played, I can see that on average each user plays 72% of the games they own. Anecdotally, that seems pretty accurate. I’ve actually only played roughly half of the games in my library because of random games I’ve picked up from sales and bundles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*pVQfZY6PqV-hb-Cw" /></figure><p>Additionally, 1,043 of the users in this data have not played <em>any</em> of the games they own. Your guess why is as good as mine on that one.</p><h3>Playtime</h3><p>Of course the other side of that question is just how many hours have people played? Well in this data, the average across all users is 278.5 hours. That sounds like a lot, but keep in mind that’s a lifetime statistic.</p><p>Looking at that data from the game perspective instead of the user, each of the 5155 games was owned by an average of 25 people, and had an average of 669.7 total hours played. Further, 1555 of the games in this set were owned but never played at all.</p><p>Since there’s not as much relational data in this set, here’s a couple top 10 lists:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/0*yvNOVBxO6NJbe4VL" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/0*lklQgYSbgfmCGWHu" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*s012NFL3PyNweFvZ" /></figure><p>I guess some people really like their sports games!</p><h3>Combining Sets</h3><p>All of that so far is interesting, but what I had really wanted was to see what both sets together could tell me. That starts with finding the common ground between them.</p><p>Just doing simple comparison, I only found 8 games that were common between the two datasets. I dug a bit further with some similarity comparisons, and found 4 more for a total of 12 games. Since that is all I found, at least I can easily show it all here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O3y0LzrjtIkAy9R3" /></figure><p>I had really hoped to find more, but while comparing different games I found why there was so little overlap. The two sets were taken from different time periods! While the first set had reviews ranging from December 2010 through February 2019, the games it had were mostly recent releases. The second dataset didn’t mention any time period at all in its description, but the games it includes show that it was a bit older. For example, the first set included Football Manager 2019, while the second dataset had entries for each of the Football Manager games from 2009–2016. So while 12 games is far too low of a sample size to draw any definitive conclusions, we can at least look at some of the relationships here.</p><h3>Average playtime of reviewers vs all players</h3><p>Do players who leave reviews for games play more than those that don’t?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*ATrcrdCXhfS3Fqag" /></figure><p>Well it certainly looks like they do. In fact, many of the reviewers played ten times more than all players, shown by the orange line. Keep in mind though, that this is only 12 games out of the thousands on Steam. Also, since we know the reviews data is more recent, perhaps those players have simply had more time to play.</p><h3>Recommendations vs hours played</h3><p>Earlier we looked for a relationship between how long reviewers played and how much it was recommended. There was not a strong relationship there, but is that true when looking at the playtime of all users?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*A_1rCrLiKKeXMRUt" /></figure><p>This actually shows the opposite of what we had before. When just looking at reviewer playtime, we saw that players who played more were slightly more likely to recommend their games. But out of the 12 games we had in common, the only 3 games with less than 90% recommendations were also the three most played on average. It would definitely be interesting to check this again with more complete data.</p><h3>Final thoughts</h3><p>So I was not able to find some of the cool cross-dataset insights I was hoping for. This still showed some interesting things, and even challenged my assumption that people who didn’t recommend a game weren’t likely to play it much. Steam no longer makes user data as accessible as it used to, but I would definitely like to revisit these observations if I can get more complete and up to date data.</p><p>And last but not least, here is my jupyter notebook where you can see my raw work: <a href="https://github.com/jonDuke/jonDuke.github.io/blob/master/notebooks/Steam_Data_Analysis.ipynb">https://github.com/jonDuke/jonDuke.github.io/blob/master/notebooks/Steam_Data_Analysis.ipynb</a></p><p>You can also read this on my own portfolio site here: <a href="https://jonduke.github.io/2019-02-06-steam-data-project/">https://jonduke.github.io/2019-02-06-steam-data-project/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a4ff3c5ce1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>