<?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 Michael Tiernan on Medium]]></title>
        <description><![CDATA[Stories by Michael Tiernan on Medium]]></description>
        <link>https://medium.com/@michael-tiernan?source=rss-846867f81f3d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*p0yzFDzv39pldYmKMmoSaQ.png</url>
            <title>Stories by Michael Tiernan on Medium</title>
            <link>https://medium.com/@michael-tiernan?source=rss-846867f81f3d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 18:30:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michael-tiernan/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[Navigating Data And Telling A Story]]></title>
            <link>https://michael-tiernan.medium.com/navigating-data-and-telling-a-story-57e7eb254661?source=rss-846867f81f3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/57e7eb254661</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[vegas-lines]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[baseball]]></category>
            <category><![CDATA[nike]]></category>
            <dc:creator><![CDATA[Michael Tiernan]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 19:13:53 GMT</pubDate>
            <atom:updated>2021-07-21T19:13:53.446Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DVfl4UuqYojEMNm2.jpg" /></figure><p>As someone who has 6+ years in the market research industry, first starting out programming surveys using HTML, CSS, JavaScript, to then landing my next job enhancing databases upon client request and becoming knowledgeable about the overall life-cycle of the data — from data input to final deliverables, and now as a recent graduate of Flatiron’s 10-month long part-time Immersive Data Science Bootcamp Program, I’ve really seen all aspects of the industry.</p><p>Evaluating my past experiences to the past 10 months, I can honestly say that nothing is more rewarding, challenging, and insightful then the process of a data scientist. In a world where data is captured at every second, the opportunities are endless and you truly have the ability to complete insightful projects at your fingertips.</p><p>With that said, I want to share a few insightful visuals because what I’ve come to find is that the most rewarding part of this journey is when you get to tell the story of your data/findings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*HAWmkN57yUYpzl21FeBmZw.png" /></figure><p>This first visual was a simple, yet insightful one. I did an analysis on Nike’s stock price using Time Series modeling. Looking at the full history of the Close price, from 12/2/1980–4/29/2021, breaking it out by the average by month, I found that May and June are the best times to buy Nike stock. As you can see from the graph below, these are the months where the stock is the lowest. When you see this and compound it with your real-world knowledge that these are the summer months before back-to-school and the holiday season, it makes sense that May and June are historically low months in terms of Nike’s stock price. The stock then shows strong performance from September to the next April, after public interest has settled after the release of their Q3 earnings at the end of March, and before coming down for the summer months again. I do need to say, I do not recommend this analysis to be used for real-world trading purposes as there are many factors not accounted for that do affect stock price, but it was encouraging to see that it looks like this trend is holding true this year, as the stock just recently made a significant jump at the end of June’21.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a0KUbDrDvv2vtom0dqZS6A.png" /></figure><p>This second visual was a fun one that shows the significance of the home run when it comes to being inducted into the MLB Hall Of Fame. Above, you can see a distribution of all players’ career home run stats, with the orange data points resembling HOF players vs. the blue data points of those non-HOF players. I labeled the top 10 all-time HR leaders, which was fun — but also important to denote because you can clearly see how some of the all-time HR leaders are non-HOFers. If you are familiar with baseball, you know the names of these players, and you also know that they were banned from being inducted into the HOF due to being caught using performing-enhancing drugs, hence the blue data point. The fact that these players were leaders in HRs (as well as other stats) and non-HOFers, they were incorrectly skewing my data, and ultimately throwing off my Random Forest Classification model when <a href="https://github.com/MJ-AllDay-67/Classifying_MLB_HOF_Players">predicting a HOF player</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aEhPMzM6ApgYNUNXx1qvhw.png" /></figure><p>My last visual was an extremely insightful one. I was able to scrape the Vegas lines for MLB teams’ season total wins from 2014–2019. I joined this data to historic team data broken out by year and compared the Vegas line to the actual number of wins each team had for that given year. What I found is that the bookmakers in Vegas are EXTREMELY accurate! To get a little technical — specifically, what I found is that the standard deviation of the bookmakers predicted season total wins was only 7.92 games. The standard deviation tells us how spread out the data is, the higher the number, the greater the distance is to the mean of the data. There are 162 regular season games in a typical MLB season, the mean of both the Vegas lines and the actual win totals was nearly similar at 81 (which makes sense because every game has a winner and a loser), so what we can conclude from looking at the standard deviation of the Vegas lines is that the bookmakers are within 8 games 68% of the time, and within 16 games (2 standard deviations) 95% of the time (these percentages are understood by definition). This is wildly accurate for predicting a sport that is widely considered the hardest sport to predict!</p><p>What made this visual and analysis so rewarding was that when I tried Googling things like “accuracy of Vegas lines” or “how accurate are Vegas lines,” I could not find any research or articles that provided hard numbers like the ones I was able to draw from my analysis. I encourage you to test me on this and comment with your findings.</p><p>With that said, this journey has only encouraged me to do more. I have a list of project ideas that I am ready to tackle as well as different techniques I am excited to explore and implement like neural networks and recommendation systems. Maybe this encourages you to get involved as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57e7eb254661" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting Baseball]]></title>
            <link>https://michael-tiernan.medium.com/predicting-baseball-f09a38f321a?source=rss-846867f81f3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f09a38f321a</guid>
            <dc:creator><![CDATA[Michael Tiernan]]></dc:creator>
            <pubDate>Tue, 20 Jul 2021 03:12:44 GMT</pubDate>
            <atom:updated>2021-07-20T03:12:44.729Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAuvlp_X72zrsJQRnm0WCw.jpeg" /></figure><p>Is it possible? If you read my last post, <a href="https://michael-tiernan.medium.com/mlb-vegas-lines-vs-actual-results-2c479f035e7">MLB Vegas Lines vs. Actual Results</a>, its pretty clear that yes, it is possible to predict America’s game. Baseball is considered one of the hardest sports to bet on, but when you have the resources and years of mastery that the Vegas bookmakers have, you see that it is possible. When you are one person on a two-month deadline, and are a recent graduate of Flatiron’s 10-month long part-time Immersive Data Science bootcamp…it’s a pretty tall order to see that same result for yourself.</p><p><strong>The Process:</strong></p><p>The task at the very highest level is pretty simple, collect as much data as you can find and basically tell the computer to find correlations (some hidden some not) in the data, run statistically backed machine learning algorithms, and spit out a money-making prediction!</p><p>Of course, its not that simple. Getting and formatting the data into a clean working database that is ready for analysis and machine learning is by far the most time-consuming exercise in this process. It requires a plan, one that needs to be detailed and broken down on a weekly and daily basis so that you stay the course, holding yourself accountable, and ultimately progressing towards that end goal. I’ll spare you all the frustrations that comes along with this process, but just know that part of the reason you are updating this plan daily is because some of the smallest tasks will take you significantly longer than you expected…and I mean SIGNIFICANTLY longer! Once you have the data cleaned and formatted, you can run analysis and models. After running baseline models, you then evaluate them and tune them to make them better and increase their predictability. Now that I’ve given you a small peak into the process of a data scientist, lets get back to the high-level conversation.</p><p><strong>The Data:</strong></p><p>I originally set out to predict season total wins for MLB teams. So what goes into this? I started with yearly stats for each team (Hits, Runs, RBIs, BA, ERA, Errors, etc.) that I thought covered the three aspects of the sport, hitting, pitching, and fielding. From there I calculated some of my own stats, which is also known as feature engineering. For example, I took runs scored and subtracted runs against to create each teams’ run differential. The correlation this new feature had to season total wins was extremely positive. This was my most predictive feature, which you can see from the heatmap below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*ScHrbzCkcCe4yepOyS6-bg.png" /></figure><p>Linear Regression:</p><p>I chose to start with a linear regression model as my baseline because almost all of the yearly stats had a linear correlation to season total wins. Any features that were not linearly correlated were removed. This check for linearity is one of the assumptions that linear regression models assume about your data before actually running the model. I have listed all three assumptions that need to be met here:</p><p>1) Linearity — features have linear relationship to target column (wins in this example).</p><p>2) Multicolinearity — features are independent of each other</p><p>3) Residuals are normally distributed and have a mean of zero</p><p>This baseline model actually had impressive results as my R-squared was 91%. R-squared is an evaluation metric that explains the proportion of variance between the predicted and observed values. It is a value between 1 and 0, where the higher the value, the less variance there is between the predicted and observed. Another important evaluation metric is root mean squared error (RMSE), which again measures error between the predicted and observed, but the importance of this measure comes in handy when comparing results from one model to the next.</p><p>After normalizing all features and removing some outliers, I ran a second linear regression model that increased my R-squared to 92% and resulted in a much better RMSE of 28% in the training data and 30% on the test data.</p><p>Decision Trees and Random Forest:</p><p>Next I ran some more advanced models like Decision Trees and Random Forest. Random Forest algorithm is a collection of Decision Tree tests that then evaluates all combinations of your features and takes the average of all tests run and outputs the metrics based on this average. The math behind this algorithm goes back to elementary school when you had to guess the number of jelly beans in a jar. While there are sure to be guesses that are too big or too small, the more responses you get, the closer the average of all of those guess will be to the actual number of jelly beans in the jar.</p><p>I paired these algorithms with a tuning method called GridSearch. This method, put into a pipeline, essentially tests a range of parameters for your models to then run tests on each and every combination of values in the range of parameters and again results in the best parameters to use for running the most predictive model.</p><p>My most predictive model was a Random Forest Regressive model paired with GridSearch. The R-squared on the training data was 95% and 89% on the test data. While it was encouraging to see such positive results, I then wanted to see which features the model took into account and how they were weighted.</p><p>This is where it became a bit of an underwhelming result. As you can see from the chart below, the model resulted in run differential being heavily weighted compared to all the other features. This is because the correlation is so strong compared to the others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*TnEzb0MHQxv6thCo_NcrWQ.png" /></figure><p>After all of that work, it was a bit disappointing to see that one feature was the main driver of my model’s prediction. I searched for more yearly stats, but it was time to take my analysis a different direction.</p><p>Conclusion and Future Work:</p><p>Before I conclude, time constraints do limit how far one can take an analysis so part of every project for Flatiron, we explain how we can improve our analysis in the future. I explained in the beginning of this post how a plan is needed, and while I had many more things that I wanted to accomplish, I was unable to in the time given. In order to more accurately predict America’s game, in the future I would like to bring in lineups and player stats to more accurately define the chemistry of each team. Pitchers need to be broken down to the pitches they throw and how their effectiveness matches up to each hitter in the opposing team’s lineup. To do it correctly, you really need to start at the most micro level and build up to the macro level that I showed here.</p><p>In the future I plan to analyze 1 pitcher’s pitch vs. 1 hitter’s swing. This then needs to be built out for an entire lineup and over a season’s length for each team.</p><p>In my next post, you can see how I pivoted to modeling single-game wins because at the end of the day, when you want to predict season total wins, you do need to know what are the most predictive features that go into predicting a single game win first.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f09a38f321a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MLB Vegas Lines vs. Actual Results]]></title>
            <link>https://michael-tiernan.medium.com/mlb-vegas-lines-vs-actual-results-2c479f035e7?source=rss-846867f81f3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c479f035e7</guid>
            <category><![CDATA[vegas-lines]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[predictive-modeling]]></category>
            <category><![CDATA[baseball]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Michael Tiernan]]></dc:creator>
            <pubDate>Fri, 16 Jul 2021 21:36:59 GMT</pubDate>
            <atom:updated>2021-07-16T21:36:59.358Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently finished a <a href="https://github.com/MJ-AllDay-67/Predicting_Baseball">project</a> where I set out to predict both individual games and season total wins for baseball. As I gathered my data and began my EDA (exploratory data analysis), I found myself going down a constant rabbit hole of questions that would dramatically shift the way in which I approach and ultimately navigate myself through this time-sensitive project. Somewhere in this rabbit hole I thought <strong>if I’m trying to predict the sport, I first need to know how accurate the Vegas bookmakers are and use that as my benchmark for my model’s performance. </strong>Naturally, I took to Google to look for any past research or articles on this topic. Surprisingly (or maybe not), Google did not return anything that I was looking for in terms of hard numbers.</p><p>From there I went searching for a history of Vegas lines on past individual games and season total wins so that I can compare the results on my own. Using the L<a href="http://www.seanlahman.com/baseball-archive/statistics/">ahman’s Baseball Database</a>, I already had each teams’ actual win totals for every season dating back to 1871. While I was unsuccessful in finding odds for each individual game, I was able to scrape the Vegas lines for season total wins for each team going back to 2014. This was it! Now that I had this, I quickly joined it to the Lahman’s database so that I can compare the actual vs. the predicted Vegas line for an MLB teams’ season win total.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*-z-rXxBzVvTS5P41Ted2dQ.png" /><figcaption>columns going left to right: (Year, Team, Actual Win Total, Predicted Vegas Win Total)</figcaption></figure><p>What I found, and what you can see from both the above and below images, is that Vegas is <strong>EXTREMELY</strong> accurate!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A8XLTbvEXCo0utwYmoqhdw.png" /></figure><p>To get a little technical — specifically, what I found is that the standard deviation of the bookmakers predicted season total wins was only 7.92 games. The standard deviation tells us how spread out the data is, the higher the number, the greater the distance is to the mean of the data. There are 162 regular season games in a typical MLB season, the mean of both the Vegas lines and the actual win totals was nearly similar at 81 (which makes sense because every game has a winner and a loser), so what we can conclude from looking at the standard deviation of the Vegas lines is that the bookmakers are within 8 games 68% of the time, and within 16 games (2 standard deviations) 95% of the time (these percentages are understood by definition). This is wildly accurate for predicting a sport that is widely considered the hardest sport to predict!</p><p>While this was only a small piece to my overall project on predicting individual and season total wins, it was a very rewarding and insightful personal win that had me thinking…</p><p>“I BEAT GOOGLE!”</p><p>If interested, I encourage you to Google things like “how accurate are Vegas lines” or “accuracy of Vegas lines” and comment with what you find.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c479f035e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taking Your First Data Science Project From Start to Finish]]></title>
            <link>https://michael-tiernan.medium.com/taking-your-first-data-science-project-from-start-to-finish-a50e5f46702e?source=rss-846867f81f3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a50e5f46702e</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[pandas-dataframe]]></category>
            <category><![CDATA[web-scraping]]></category>
            <dc:creator><![CDATA[Michael Tiernan]]></dc:creator>
            <pubDate>Mon, 02 Nov 2020 17:41:59 GMT</pubDate>
            <atom:updated>2020-11-02T17:41:59.457Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*HW85Rvkft3nVczQykZgnfQ.jpeg" /></figure><p>I know when I first started my data science journey, I googled trying to find a quick overview of a project because I wanted to see each part of the process just to get a glimpse into what the code looks like for each step. As someone who works with data, but is new to data science, I thought, if I can just get a glimpse from start to finish, it would help me understand at a high level, just how much (or little) code it takes to uncover your own findings.</p><p>So that is what I am going to do here, a brief 3 steps showing some code from each. To paint a quick picture of my personal situation, I am enrolled in a part-time online DS bootcamp, while working a full-time job. I work in a high-pace, strict-deadline market research job, so the balancing of that with the hyper-speed of being in a bootcamp, learning two topics per week with a laundry list of reading, and labs, and reading external resources, and solving extra problems posted by the teacher has all been simply put… a lot!</p><p>With that said, I have found a daily routine that works for me, but I am still figuring it out and trying to improve on it each day. I think I’ll write about that in my next post, but for now, let’s get back to taking your first data science project from start to finish.</p><p><strong>Step 1: Get The Data</strong></p><p>We were given DBs to work with, but my team and I decided to test ourselves on webscraping. This was the first time scraping for each of us, and I would have to say we did a damn good job. The data I found comes from a website where you are shown a table of the Netflix daily top 10. My job now is to target the HTML using Chrome’s inspector tool (right-click ‘inspect’) and pull the data from how it is presented on the website, iterate through each column, on each page (previous page shows previous day’s Top 10), and lastly, get it into a pandas dataframe. Here is how I scraped the data I found using BeautifulSoup and request libraries:</p><pre>title1 = []<br>types1 = []<br>days1 = []<br>scores1 = []<br><br><strong>for</strong> i <strong>in</strong> range(1,30):<br>    url_netflix = &#39;https://www.the-numbers.com/home-market/netflix-daily-chart/2020/06/<strong>{}</strong>&#39;.format(i)<br>    response_ntflx = requests.get(url_netflix)<br>    soup = BeautifulSoup(response_ntflx.content, &#39;html.parser&#39;)<br>    <br>    z = soup.find_all(&#39;td&#39;)<br>    <br>    z.pop(0)<br>    z.pop(0)<br>    z.pop(0)<br>    <br>    <em># TITLE - FIRST INSTANCE</em><br>    title = z[3::10]<br>    <br>    <strong>for</strong> titl <strong>in</strong> title:<br>        title1.append(titl.text)<br>    <br>    <em># TYPE - FIRST INSTANCE</em><br>    types = z[4::10]<br>    <br>    <strong>for</strong> typ <strong>in</strong> types:<br>        types1.append(typ.text)<br>    <br>    days = z[7::10]<br>    <br>    <strong>for</strong> day <strong>in</strong> days: <br>        days1.append(day.text)<br>        <br>    scores = z[8::10]<br>    <br>    <strong>for</strong> score <strong>in</strong> scores:<br>        scores1.append(score.text)</pre><p>What the code above is doing, is identifying the first row of each column and then iterating through to grab the other 9 elements from each column of the Top 10. This process had its growing pains, so the moment you see the data in your own working dataframe is your first big victory!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*cxvMML9Tnlib_w2xfr4aQw.png" /></figure><p><strong>Step 2: Cleaning The Data and Exploratory Data Analysis (EDA)</strong></p><p>I put cleaning and EDA as one step because in order to clean your data, you have to get to know it, so the two happen simultaneously. Here I checked for null values, duplicate entries, outliers and extraneous values. I renamed columns, changed column types (converting string fields to floats), and got to know my data by performing groupby’s and sorting.</p><pre>kaggle_grouped = kaggle.groupby([&#39;release_year&#39;,&#39;type&#39;])[&#39;title&#39;].count().reset_index()<br>kaggle_grouped.tail(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*DnS9piAAll8UIZCPEG2d-g.png" /></figure><p><strong>Step 3: Visualizations and Creating Your Story</strong></p><p>This step, much like the one above, I combined what some may say are two steps, into one step because as you create the visualizations you are learning and curating the story that the data is telling you. A helpful hint here is sometimes the simpler, the better.</p><pre>fig,ax = plt.subplots(figsize=(10,6))<br>ax.set(xlabel=&#39;Year of Release&#39;, ylabel=&#39;Number of Titles&#39;)<br>ax = sns.lineplot(x=&#39;release_year&#39;, y=&#39;title&#39;, data=kaggle_filtered, hue=&#39;type&#39;, markers=<strong>True</strong>, palette=&#39;inferno&#39;).set_title(&quot;TV Show vs. Movies (2007-2019)&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*ELH_BuKxcGsGtYCWmlGASg.png" /></figure><p>My team and I had two weeks to complete this assignment. What we found is that we should focus on TV Shows rather than movies because as you can see from the chart above, TV Shows are still on an upward trend while movies are not. TV Shows also dominated the Netflix Top 10 as opposed to the amount of movies on a daily basis. We went further and looked by network and by genre, also pulling in awards data, but for the purposes of this post I think you get the point.</p><p>So if you are just beginning your journey, hopefully you find this post helpful and maybe showed you that you can start simple and still accomplish a great deal. Keep going!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a50e5f46702e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>